Java 类com.badlogic.gdx.Graphics.DisplayMode 实例源码

项目:Protoman-vs-Megaman    文件:VideoMenuPage.java   
@Override
public void initialize() {
    currentMode = Integer.parseInt(GameUtils.getCfgPreferenceValue(GameConstants.PREFERENCE_KEY_WIDTH));

    availableResolutions43 = new TreeMap<Integer, Integer>();
    availableResolutions43.put(currentMode, Integer.parseInt(GameUtils.getCfgPreferenceValue(GameConstants.PREFERENCE_KEY_HEIGHT)));

    DisplayMode[] displayModes = Gdx.graphics.getDisplayModes();
    // store all remaining 4:3 resolutions
    final double aspect43 = 4.0 / 3.0;
    for (DisplayMode mode : displayModes) {
        // get current game resolution mode
        double aspect = 1.0 * mode.width / mode.height;
        if (aspect == aspect43 && !availableResolutions43.containsKey(mode.width)) {
            availableResolutions43.put(mode.width, mode.height);
        }
    }

    boolean fullscreen = Boolean.parseBoolean(GameUtils.getCfgPreferenceValue(GameConstants.PREFERENCE_KEY_FULLSCREEN));
    addOption(GameUtils.getLocalizedLabel("MainMenu.option.settings.video.fullscreen"), true, MegamanConstants.MENU_OFFSET_TOP, 0, 0, 0);
    addOption("" + fullscreen, false, skin.get("menu_suboption", LabelStyle.class), 0, 0, MegamanConstants.MENU_PADDING_BETWEEN_OPTIONS / 2, 0);
    addOption(GameUtils.getLocalizedLabel("MainMenu.option.settings.video.windowSize"), !fullscreen, !fullscreen ? skin.get("default", LabelStyle.class) : skin.get("menu_option_disabled", LabelStyle.class), 0, 0, 0, 0);
    addOption("" + currentMode + " x " + availableResolutions43.get(currentMode), false, skin.get("menu_suboption", LabelStyle.class), 0, 0, MegamanConstants.MENU_PADDING_BETWEEN_OPTIONS / 2, 0);
    addOption(GameUtils.getLocalizedLabel("MainMenu.option.back"), true, 0, 0, 0, 0);
}
项目:libgdxcn    文件:LwjglApplicationConfiguration.java   
/** Sets the r, g, b and a bits per channel based on the given {@link DisplayMode} and sets the fullscreen flag to true.
 * @param mode */
public void setFromDisplayMode (DisplayMode mode) {
    this.width = mode.width;
    this.height = mode.height;
    if (mode.bitsPerPixel == 16) {
        this.r = 5;
        this.g = 6;
        this.b = 5;
        this.a = 0;
    }
    if (mode.bitsPerPixel == 24) {
        this.r = 8;
        this.g = 8;
        this.b = 8;
        this.a = 0;
    }
    if (mode.bitsPerPixel == 32) {
        this.r = 8;
        this.g = 8;
        this.b = 8;
        this.a = 8;
    }
    this.fullscreen = true;
}
项目:libgdxcn    文件:LwjglApplicationConfiguration.java   
public static DisplayMode[] getDisplayModes () {
    GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice device = genv.getDefaultScreenDevice();
    java.awt.DisplayMode desktopMode = device.getDisplayMode();
    java.awt.DisplayMode[] displayModes = device.getDisplayModes();
    ArrayList<DisplayMode> modes = new ArrayList<DisplayMode>();
    int idx = 0;
    for (java.awt.DisplayMode mode : displayModes) {
        boolean duplicate = false;
        for (int i = 0; i < modes.size(); i++) {
            if (modes.get(i).width == mode.getWidth() && modes.get(i).height == mode.getHeight()
                && modes.get(i).bitsPerPixel == mode.getBitDepth()) {
                duplicate = true;
                break;
            }
        }
        if (duplicate) continue;
        if (mode.getBitDepth() != desktopMode.getBitDepth()) continue;
        modes.add(new LwjglApplicationConfigurationDisplayMode(mode.getWidth(), mode.getHeight(), mode.getRefreshRate(), mode
            .getBitDepth()));
    }

    return modes.toArray(new DisplayMode[modes.size()]);
}
项目:libgdxcn    文件:FullscreenTest.java   
@Override
public void render () {
    Gdx.gl.glClearColor((float)Math.random(), 0, 0, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    if (Gdx.input.justTouched()) {
        if (fullscreen) {
            Gdx.graphics.setDisplayMode(480, 320, false);
            fullscreen = false;
        } else {
            DisplayMode desktopDisplayMode = Gdx.graphics.getDesktopDisplayMode();
            Gdx.graphics.setDisplayMode(desktopDisplayMode.width, desktopDisplayMode.height, true);
            fullscreen = true;
        }
    }
}
项目:seventh    文件:ClientMain.java   
/**
 * Attempts to find the best display mode
 * @param config 
 * @return the best display mode
 * @throws Exception
 */
private static DisplayMode findBestDimensions(VideoConfig config) throws Exception {

    if(config.isPresent()) {

        int width = config.getWidth();
        int height = config.getHeight();

        DisplayMode[] modes = LwjglApplicationConfiguration.getDisplayModes();
        for(DisplayMode mode : modes) {
            if(mode.width == width && mode.height == height) {
                return mode;
            }
        }
    }

    return LwjglApplicationConfiguration.getDesktopDisplayMode();
}
项目:c2d-engine    文件:JarExportableCmd.java   
/**
 * This command only run on desktop . Add this , you can export the project 
 * into a jar to run it
 */
public static final void process(){
    final EngineCallback callback = Engine.getEngineCallback();
    Engine.setEngineCallback(new EngineCallback() {
        @Override
        public void preLoad(DisplayMode mode, String[] assets) {
            //the sort is important , do not change it
            Engine.getAliasResourceManager().setLoopLoader(new LoopLoaderJar());
            callback.preLoad(mode, assets);
        }

        @Override
        public void postLoad() {
            callback.postLoad();
        }
    });
}
项目:M-M    文件:SettingsController.java   
/** @return array of serialized display modes' names. */
@LmlAction("displayModes")
public Array<String> getDisplayModes() {
    final ObjectSet<String> alreadyAdded = GdxSets.newSet(); // Removes duplicates.
    final Array<String> displayModes = GdxArrays.newArray(); // Keeps display modes sorted.
    for (final DisplayMode mode : fullscreenService.getDisplayModes()) {
        final String modeName = fullscreenService.serialize(mode);
        if (alreadyAdded.contains(modeName)) {
            continue; // Same size already added.
        }
        displayModes.add(modeName);
        alreadyAdded.add(modeName);
    }
    return displayModes;
}
项目:M-M    文件:SettingsController.java   
/** @param actor its ID must match name of a display mode. */
@LmlAction("setFullscreen")
public void setFullscreenMode(final Actor actor) {
    final String modeName = LmlUtilities.getActorId(actor);
    final DisplayMode mode = fullscreenService.deserialize(modeName);
    fullscreenService.setFullscreen(mode);
}
项目:M-M    文件:FullscreenService.java   
/** @param displayMode serialized display mode. See {@link #serialize(DisplayMode)}.
 * @return mode instance or null with selected size is not supported. */
public DisplayMode deserialize(final String displayMode) {
    final String[] sizes = Strings.split(displayMode, 'x');
    final int width = Integer.parseInt(sizes[0]);
    final int height = Integer.parseInt(sizes[1]);
    for (final DisplayMode mode : Gdx.graphics.getDisplayModes()) {
        if (mode.width == width && mode.height == height) {
            return mode;
        }
    }
    return null;
}
项目:M-M    文件:FullscreenService.java   
/** @param displayMode must support fullscreen mode. */
public void setFullscreen(final DisplayMode displayMode) {
    if (Gdx.graphics.setFullscreenMode(displayMode)) {
        // Explicitly trying to resize the application listener to fully support all platforms:
        Gdx.app.getApplicationListener().resize(displayMode.width, displayMode.height);
    }
}
项目:fabulae    文件:GameOptionsPanel.java   
private DisplayMode findFullscreenDisplayMode(Resolution resolution) {
    DisplayMode[] modes = Gdx.graphics.getDisplayModes();
    DisplayMode monitorDisplayMode = Gdx.graphics.getDisplayMode();
    DisplayMode foundDisplayMode = null;
    int freq = 0;

    for (int i = 0; i < modes.length; i++) {
        DisplayMode current = modes[i];

        if ((current.width == resolution.getWidth()) && (current.height == resolution.getHeight())) {
            if ((foundDisplayMode == null) || (current.refreshRate >= freq)) {
                if ((foundDisplayMode == null) || (current.bitsPerPixel > foundDisplayMode.bitsPerPixel)) {
                    foundDisplayMode = current;
                    freq = foundDisplayMode.refreshRate;
                }
            }

            // if we've found a match for bpp and frequence against the
            // original display mode then it's probably best to go for this one
            // since it's most likely compatible with the monitor
            if ((current.bitsPerPixel == monitorDisplayMode.bitsPerPixel)
                && (current.refreshRate == monitorDisplayMode.refreshRate)) {
                foundDisplayMode = current;
                break;
            }
        }
    }
    return foundDisplayMode;
}
项目:ChessGDX    文件:GraphicsSettings.java   
/**
 * Sets the window display mode to match the options set in preferences in
 * preferences. This is called at launch.
 */
public static void setGraphics() {
    Preferences pref = Gdx.app.getPreferences(GameCore.TITLE);
    int width = pref.getInteger(PreferenceStrings.DISPLAY_WIDTH);
    int height = pref.getInteger(PreferenceStrings.DISPLAY_HEIGHT);
    boolean fullscreen = pref.getBoolean(PreferenceStrings.FULLSCREEN);
    boolean vSync = pref.getBoolean(PreferenceStrings.VSYNC);
    if (width != 0 && height != 0) {
           if(fullscreen) {
               DisplayMode usable = Gdx.graphics.getDisplayMode();
               for(DisplayMode displayMode : Gdx.graphics.getDisplayModes()){
                   if(displayMode.width == width && displayMode.height == height){
                       usable = displayMode;
                       break;
                   }
               }
               Gdx.graphics.setFullscreenMode(usable);
           } else {
               Gdx.graphics.setWindowedMode(width, height);
           }
           Gdx.graphics.setVSync(vSync);
    } else {
           if(fullscreen) {
               Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
           } else {
               Gdx.graphics.setWindowedMode(1280, 720);
           }
           Gdx.graphics.setVSync(vSync);
    }
}
项目:Aftamath    文件:Game.java   
public void render() {
        gsm.update(STEP);
        gsm.render();
        MyInput.update();
//      System.out.println("managed textures: "+Texture.getNumManagedTextures());

         if (Gdx.input.isKeyPressed(Input.Keys.F5)) {
                fullscreen = !fullscreen;
                DisplayMode currentMode = Gdx.graphics.getDesktopDisplayMode();
                if(fullscreen)
                    Gdx.graphics.setDisplayMode(currentMode.width, currentMode.height, fullscreen);
                else
                    Gdx.graphics.setDisplayMode(width, height, fullscreen);
         }
    }
项目:Aftamath    文件:Menu.java   
public void changeWindowMode(){
       Game.fullscreen = !Game.fullscreen;
       DisplayMode currentMode = Gdx.graphics.getDesktopDisplayMode();
       MenuObj m = null;

       for(MenuObj[] l : objs){
        for(MenuObj obj : l){
            if(obj==null) continue;
            if(obj.getText()==null) continue;
            if(obj.getText().equals("WINDOWED") || 
                    obj.getText().equals("FULLSCREEN")){
                m = obj;
                break;
            }
        }
        if(m!=null) break;  
       }    

       if(Game.fullscreen){
        Gdx.graphics.setDisplayMode(currentMode.width, currentMode.height, Game.fullscreen);
        if(m!=null) {
            m.setText("FULLSCREEN");
        //move text
        }
       } else {
        Gdx.graphics.setDisplayMode(Game.width, Game.height, Game.fullscreen);
        if(m!=null) {
            m.setText("WINDOWED");
        }
       }
}
项目:Roguelike    文件:LwjglApplicationChanger.java   
@Override
public void updateApplication( Preferences pref )
{
    System.setProperty( "org.lwjgl.opengl.Window.undecorated", "" + pref.getBoolean( "borderless" ) );

    int width = pref.getInteger( "resolutionX" );
    int height = pref.getInteger( "resolutionY" );
    boolean fullscreen = pref.getBoolean( "fullscreen" );

    Global.TargetResolution[0] = width;
    Global.TargetResolution[1] = height;
    Global.FPS = pref.getInteger( "fps" );
    Global.AnimationSpeed = 1.0f / pref.getFloat( "animspeed" );

    Global.MovementTypePathfind = pref.getBoolean( "pathfindMovement" );
    Global.MusicVolume = pref.getFloat( "musicVolume" );
    Global.AmbientVolume = pref.getFloat( "ambientVolume" );
    Global.EffectVolume = pref.getFloat( "effectVolume" );
    Global.updateVolume();

    for ( Controls.Keys key : Controls.Keys.values() )
    {
        Global.Controls.setKeyMap( key, pref.getInteger( key.toString() ) );
    }

    if (fullscreen)
    {
        DisplayMode mode = Gdx.graphics.getDisplayMode();
        Gdx.graphics.setFullscreenMode( mode );
    }
    else
    {
        Gdx.graphics.setWindowedMode( width, height );
    }

    //Gdx.graphics.setVSync( pref.getBoolean( "vSync" ) );
}
项目:Roguelike    文件:LwjglApplicationChanger.java   
@Override
public void setToNativeResolution( Preferences prefs )
{
    DisplayMode dm = Gdx.graphics.getDisplayMode();

    prefs.putInteger( "resolutionX", dm.width );
    prefs.putInteger( "resolutionY", dm.height );

    updateApplication( prefs );
}
项目:nvlist    文件:DesktopGraphicsUtil.java   
/**
 * @return The new windowed size for the application after applying the safe window size limits.
 */
public static Dim limitInitialWindowSize(Graphics graphics) {
    if (graphics.isFullscreen()) {

        // If fullscreen, we fill the entire screen already so nothing needs to be done

    } else {
        // Width/height of the window in physical pixels
        int w = graphics.getBackBufferWidth();
        int h = graphics.getBackBufferHeight();

        // Limit window size so it fits inside the current monitor (with a margin for OS bars/decorations)
        DisplayMode displayMode = graphics.getDisplayMode();
        int maxW = displayMode.width - 100;
        int maxH = displayMode.height - 150;

        int dw = Math.min(0, maxW - w);
        int dh = Math.min(0, maxH - h);
        graphics.setWindowedMode(w + dw, h + dh);

        // Also change the window's position so it's centered on its previous location
        Lwjgl3Window window = getCurrentWindow();
        window.setPosition(window.getPositionX() - dw / 2, window.getPositionY() - dh /  2);
    }

    return Dim.of(graphics.getBackBufferWidth(), graphics.getBackBufferHeight());
}
项目:libgdxcn    文件:JglfwApplicationConfiguration.java   
static public DisplayMode[] getDisplayModes () {
    GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    java.awt.DisplayMode desktopMode = device.getDisplayMode();
    java.awt.DisplayMode[] displayModes = device.getDisplayModes();
    Array<DisplayMode> modes = new Array();
    outer:
    for (java.awt.DisplayMode mode : displayModes) {
        for (DisplayMode other : modes)
            if (other.width == mode.getWidth() && other.height == mode.getHeight() && other.bitsPerPixel == mode.getBitDepth())
                continue outer; // Duplicate.
        if (mode.getBitDepth() != desktopMode.getBitDepth()) continue;
        modes.add(new JglfwDisplayMode(mode.getWidth(), mode.getHeight(), mode.getRefreshRate(), mode.getBitDepth()));
    }
    return modes.toArray(DisplayMode.class);
}
项目:libgdxcn    文件:LwjglApplicationConfiguration.java   
public static DisplayMode getDesktopDisplayMode () {
    GraphicsEnvironment genv = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice device = genv.getDefaultScreenDevice();
    java.awt.DisplayMode mode = device.getDisplayMode();
    return new LwjglApplicationConfigurationDisplayMode(mode.getWidth(), mode.getHeight(), mode.getRefreshRate(),
        mode.getBitDepth());
}
项目:libgdxcn    文件:AndroidInput.java   
public AndroidInput (Application activity, Context context, Object view, AndroidApplicationConfiguration config) {
    // we hook into View, for LWPs we call onTouch below directly from
    // within the AndroidLivewallpaperEngine#onTouchEvent() method.
    if (view instanceof View) {
        View v = (View)view;
        v.setOnKeyListener(this);
        v.setOnTouchListener(this);
        v.setFocusable(true);
        v.setFocusableInTouchMode(true);
        v.requestFocus();
    }
    this.config = config;
    this.onscreenKeyboard = new AndroidOnscreenKeyboard(context, new Handler(), this);

    for (int i = 0; i < realId.length; i++)
        realId[i] = -1;
    handle = new Handler();
    this.app = activity;
    this.context = context;
    this.sleepTime = config.touchSleepTime;
    touchHandler = new AndroidMultiTouchHandler();
    hasMultitouch = touchHandler.supportsMultitouch(context);

    vibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);

    int rotation = getRotation();
    DisplayMode mode = app.getGraphics().getDesktopDisplayMode();
    if (((rotation == 0 || rotation == 180) && (mode.width >= mode.height))
        || ((rotation == 90 || rotation == 270) && (mode.width <= mode.height))) {
        nativeOrientation = Orientation.Landscape;
    } else {
        nativeOrientation = Orientation.Portrait;
    }
}
项目:libgdxcn    文件:FullscreenTest.java   
@Override
public void create () {
    DisplayMode[] modes = Gdx.graphics.getDisplayModes();
    for (DisplayMode mode : modes) {
        System.out.println(mode);
    }
    Gdx.app.log("FullscreenTest", Gdx.graphics.getBufferFormat().toString());
}
项目:HAW-SE2-projecthorse    文件:AndroidPlatform.java   
@Override
public void setOrientation(Orientation orientation) {
    active = orientation;
    if (orientation == Orientation.Landscape) {
        DisplayMode[] DisplayModes = Gdx.graphics.getDisplayModes();
        Gdx.graphics.setDisplayMode(DisplayModes[0].height, DisplayModes[0].width, false);
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }else{
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }

}
项目:gaiasky    文件:PreferencesWindow.java   
private void selectFullscreen(boolean fullscreen, OwnTextField widthField, OwnTextField heightField, SelectBox<DisplayMode> fullScreenResolutions, OwnLabel widthLabel, OwnLabel heightLabel) {
    if (fullscreen) {
        GlobalConf.screen.SCREEN_WIDTH = fullScreenResolutions.getSelected().width;
        GlobalConf.screen.SCREEN_HEIGHT = fullScreenResolutions.getSelected().height;
    } else {
        GlobalConf.screen.SCREEN_WIDTH = Integer.parseInt(widthField.getText());
        GlobalConf.screen.SCREEN_HEIGHT = Integer.parseInt(heightField.getText());
    }

    enableComponents(!fullscreen, widthField, heightField, widthLabel, heightLabel);
    enableComponents(fullscreen, fullScreenResolutions);
}
项目:ingress-indonesia-dev    文件:AndroidInput.java   
public AndroidInput(AndroidApplication paramAndroidApplication, View paramView, AndroidApplicationConfiguration paramAndroidApplicationConfiguration)
{
  paramView.setOnKeyListener(this);
  paramView.setOnTouchListener(this);
  paramView.setFocusable(true);
  paramView.setFocusableInTouchMode(true);
  paramView.requestFocus();
  paramView.requestFocusFromTouch();
  this.config = paramAndroidApplicationConfiguration;
  this.onscreenKeyboard = new AndroidOnscreenKeyboard(paramAndroidApplication, new Handler(), this);
  while (i < this.realId.length)
  {
    this.realId[i] = -1;
    i++;
  }
  this.handle = new Handler();
  this.app = paramAndroidApplication;
  this.sleepTime = paramAndroidApplicationConfiguration.touchSleepTime;
  if (Integer.parseInt(Build.VERSION.SDK) >= 5);
  for (this.touchHandler = new AndroidMultiTouchHandler(); ; this.touchHandler = new AndroidSingleTouchHandler())
  {
    this.hasMultitouch = this.touchHandler.supportsMultitouch(this.app);
    this.vibrator = ((Vibrator)paramAndroidApplication.getSystemService("vibrator"));
    int j = getRotation();
    Graphics.DisplayMode localDisplayMode = this.app.graphics.getDesktopDisplayMode();
    if (((j == 0) || (j == 180)) && ((localDisplayMode.width < localDisplayMode.height) && (((j != 90) && (j != 270)) || (localDisplayMode.width > localDisplayMode.height))))
      break;
    this.nativeOrientation = Input.Orientation.Landscape;
    return;
  }
  this.nativeOrientation = Input.Orientation.Portrait;
}
项目:planetbusters    文件:ArcadeCanvas.java   
public void setDisplayMode(int width, int height, boolean fullscreen) {

        if (argument_forceWindowed) fullscreen=false;

        // return if requested DisplayMode is already set
        if ((Gdx.app.getGraphics().getWidth() == width) && 
            (Gdx.app.getGraphics().getHeight() == height) && 
            (Gdx.app.getGraphics().isFullscreen() == fullscreen)) {
            return;
        }

        if (fullscreen) {
            // just use current desktop display width*height so we know it's fullscreen correctly
            width=Gdx.app.getGraphics().getDesktopDisplayMode().width;
            height=Gdx.app.getGraphics().getDesktopDisplayMode().height;
        }


        DisplayMode targetDisplayMode = null;
        DisplayMode fallBackMode = null;

        float   baseRatio=(float)width/(float)height;   // 1,5
        float   currentRatio;


        modes = Gdx.app.getGraphics().getDisplayModes();

        if (fullscreen) {
            int freq = 0;

            for (int i=0;i<modes.length;i++) {
                DisplayMode current = modes[i];
                currentRatio=(float)current.width/(float)current.height;

                if (current.width>=width && current.height>=height && currentRatio>=baseRatio) {
                    if (current.refreshRate >= freq && current.bitsPerPixel >= Gdx.app.getGraphics().getDesktopDisplayMode().bitsPerPixel) {
                        targetDisplayMode = current;
                        currentModeID=i;
                        freq = targetDisplayMode.refreshRate;
                    }
                } else {
                    // find a "best" resolution if we can't find an exact math on ratio/w/h/bbp
                    if ((current.bitsPerPixel == Gdx.app.getGraphics().getDesktopDisplayMode().bitsPerPixel ) &&
                        (current.refreshRate == Gdx.app.getGraphics().getDesktopDisplayMode().refreshRate )) {
                        fallBackMode = current;
                        fallbackModeID=i;
                    }
                }
            }

            if (targetDisplayMode!=null) {
                Gdx.app.getGraphics().setDisplayMode(targetDisplayMode.width, targetDisplayMode.height,true);
//              Gdx.app.log("opdebug","displaymode:"+targetDisplayMode.width+"x"+targetDisplayMode.height);
            } else if (fallBackMode!=null) {
                Gdx.app.getGraphics().setDisplayMode(fallBackMode.width, fallBackMode.height,true);
                currentModeID=fallbackModeID;
            }
        } else {
            Gdx.app.getGraphics().setDisplayMode(width,height, false);
        }


        isFullScreen=fullscreen;

        if (isFullScreen) {
            Gdx.input.setCursorPosition((displayW>>1),(displayH>>1));
            Gdx.input.setCursorCatched(true);
        } else {
            Gdx.input.setCursorPosition((displayW>>1),(displayH>>1));
            Gdx.input.setCursorCatched(false);
        }


        // trigger a reinit of the controllers
        controllersFound=0;
    }
项目:M-M    文件:FullscreenService.java   
/** @return supported fullscreen display modes. Utility method. */
public DisplayMode[] getDisplayModes() {
    return Gdx.graphics.getDisplayModes();
}
项目:M-M    文件:FullscreenService.java   
/** @param displayMode will be converted to string.
 * @return passed mode converted to a string. */
public String serialize(final DisplayMode displayMode) {
    return displayMode.width + "x" + displayMode.height;
}
项目:gdx-backend-jglfw    文件:JglfwApplicationConfiguration.java   
static public DisplayMode[] getDisplayModes () {
    // FIXME
    return null;
}
项目:gdx-backend-jglfw    文件:JglfwApplicationConfiguration.java   
static public DisplayMode getDesktopDisplayMode () {
    // FIXME
    return null;
}
项目:planetbusters    文件:ArcadeCanvas.java   
public void setDisplayMode(int width, int height, boolean fullscreen) {

        if (argument_forceWindowed) fullscreen=false;

        // return if requested DisplayMode is already set
        if ((Gdx.app.getGraphics().getWidth() == width) && 
            (Gdx.app.getGraphics().getHeight() == height) && 
            (Gdx.app.getGraphics().isFullscreen() == fullscreen)) {
            return;
        }

        if (fullscreen) {
            // just use current desktop display width*height so we know it's fullscreen correctly
            width=Gdx.app.getGraphics().getDesktopDisplayMode().width;
            height=Gdx.app.getGraphics().getDesktopDisplayMode().height;
        }


        DisplayMode targetDisplayMode = null;
        DisplayMode fallBackMode = null;

        float   baseRatio=(float)width/(float)height;   // 1,5
        float   currentRatio;


        modes = Gdx.app.getGraphics().getDisplayModes();

        if (fullscreen) {
            int freq = 0;

            for (int i=0;i<modes.length;i++) {
                DisplayMode current = modes[i];
                currentRatio=(float)current.width/(float)current.height;

                if (current.width>=width && current.height>=height && currentRatio>=baseRatio) {
                    if (current.refreshRate >= freq && current.bitsPerPixel >= Gdx.app.getGraphics().getDesktopDisplayMode().bitsPerPixel) {
                        targetDisplayMode = current;
                        currentModeID=i;
                        freq = targetDisplayMode.refreshRate;
                    }
                } else {
                    // find a "best" resolution if we can't find an exact math on ratio/w/h/bbp
                    if ((current.bitsPerPixel == Gdx.app.getGraphics().getDesktopDisplayMode().bitsPerPixel ) &&
                        (current.refreshRate == Gdx.app.getGraphics().getDesktopDisplayMode().refreshRate )) {
                        fallBackMode = current;
                        fallbackModeID=i;
                    }
                }
            }

            if (targetDisplayMode!=null) {
                Gdx.app.getGraphics().setDisplayMode(targetDisplayMode.width, targetDisplayMode.height,true);
//              Gdx.app.log("opdebug","displaymode:"+targetDisplayMode.width+"x"+targetDisplayMode.height);
            } else if (fallBackMode!=null) {
                Gdx.app.getGraphics().setDisplayMode(fallBackMode.width, fallBackMode.height,true);
                currentModeID=fallbackModeID;
            }
        } else {
            Gdx.app.getGraphics().setDisplayMode(width,height, false);
        }


        isFullScreen=fullscreen;

        if (isFullScreen) {
            Gdx.input.setCursorPosition((displayW>>1),(displayH>>1));
            Gdx.input.setCursorCatched(true);
        } else {
            Gdx.input.setCursorPosition((displayW>>1),(displayH>>1));
            Gdx.input.setCursorCatched(false);
        }


        // trigger a reinit of the controllers
        controllersFound=0;
    }
项目:KittenMaxit    文件:Game.java   
@Override
public void create() {
    preferences = getPrefs();
    if (!(preferences.getBoolean("valid"))) {
        preferences = Gdx.app.getPreferences("kmaxit_pref");

        preferences.putBoolean("valid", true);

        preferences.putInteger("width", 1280);
        preferences.putInteger("height", 720);
        preferences.putFloat("scale", 1);
        preferences.putBoolean("fullscreen", false);
        preferences.putBoolean("vsync", true);
        preferences.putBoolean("fpsEnable", false);

        preferences.putFloat("soundVolume", 0.65f);
        preferences.putFloat("musicVolume", 0.8f);

        preferences.putString("playerName", "Guest");

        preferences.flush();
        Constants.loadConstants();
    } else {
        Constants.loadConstants();

        if (Constants.fullscreen && !Gdx.graphics.isFullscreen()) {
            if (Gdx.graphics.supportsDisplayModeChange()) {
                DisplayMode mode = Gdx.graphics.getDisplayMode();
                Constants.width = mode.width;
                Constants.height = mode.height;
                Constants.scale = Constants.width / 1280f;
                Gdx.graphics.setFullscreenMode(mode);
            }
        }
        Gdx.graphics.setVSync(Constants.vsync);
    }

    cursor = Gdx.graphics.newCursor(new Pixmap(Gdx.files.internal("gfx/cursors/normal.png")), 0, 0);

    music = Gdx.audio.newMusic(Gdx.files.internal("music/maintheme.ogg"));
    music.setVolume(Constants.musicVolume);
    music.play();
    music.setLooping(true);

    clickSound = Gdx.audio.newSound(Gdx.files.internal("sound/clicksound.wav"));
    hoverSound = Gdx.audio.newSound(Gdx.files.internal("sound/clicksound.wav"));

    mX = 0;
    mY = 0;

    state = 1;

    menu = new Menu(1);
    singleplayer = new Singleplayer(2);
    help = new Help(3);
    options = new Options(4);
    credits = new Credits(5);
}
项目:Protoman-vs-Megaman    文件:VideoMenuPage.java   
@Override
public boolean keyDown(int optionIndex, int keyOrButtonCode) {
    switch (optionIndex) {
        case OPTION_FULLSCREEN: {
            if (Keys.LEFT == keyOrButtonCode || Keys.RIGHT == keyOrButtonCode) {
                boolean fullscreen = Boolean.parseBoolean(GameUtils.getCfgPreferenceValue(GameConstants.PREFERENCE_KEY_FULLSCREEN));
                fullscreen = !fullscreen;

                if (fullscreen) {
                    // set window configuration to primary device
                    DisplayMode desktopDisplayMode = Gdx.graphics.getDesktopDisplayMode();
                    updateVideoConfig(desktopDisplayMode.width, desktopDisplayMode.height, fullscreen);
                } else {
                    updateVideoConfig(currentMode, availableResolutions43.get(currentMode), fullscreen);
                    Gdx.graphics.setDisplayMode(currentMode, availableResolutions43.get(currentMode), fullscreen);
                }
            } else if (Keys.ENTER == keyOrButtonCode) {
                //return true in this case to not start the selection missile
                return true;
            }

            break;
        }
        case OPTION_WINDOW_SIZE: {
            if (optionEnabled.get(OPTION_WINDOW_SIZE)) {
                if (Keys.LEFT == keyOrButtonCode) {
                    currentMode = getPreviousModeKey(currentMode);
                    updateVideoConfig(currentMode, availableResolutions43.get(currentMode), Boolean.parseBoolean(GameUtils.getCfgPreferenceValue(GameConstants.PREFERENCE_KEY_FULLSCREEN)));
                } else if (Keys.RIGHT == keyOrButtonCode) {
                    currentMode = getNextModeKey(currentMode);
                    updateVideoConfig(currentMode, availableResolutions43.get(currentMode), Boolean.parseBoolean(GameUtils.getCfgPreferenceValue(GameConstants.PREFERENCE_KEY_FULLSCREEN)));
                } else if (Keys.ENTER == keyOrButtonCode) {
                    //return true in this case to not start the selection missile
                    return true;
                }
            }
            break;
        }
    }

    return false;
}
项目:TheConsole_POC    文件:DesktopLauncher.java   
public DesktopLauncher(boolean setVisibleOnStart) {
    Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
    logger.setLevel(Level.WARNING);

    try {
        GlobalScreen.registerNativeHook();
    }
    catch (NativeHookException ex) {
        System.err
                .println("There was a problem registering the native hook.");
        System.err.println(ex.getMessage());

        System.exit(1);
    }

    GlobalScreen.addNativeKeyListener(this);


    System.setProperty("org.lwjgl.opengl.Window.undecorated", "true");

    config = new LwjglApplicationConfiguration();
    config.x = 0;
    config.y = 0;
    config.resizable = false;
    config.backgroundFPS = 45;
    config.foregroundFPS = 45;
    config.allowSoftwareMode = true;
    config.title = "The Console";
    config.width = 1;
    config.height = 1;

    app = new LwjglApplication(new TheConsole(new NativeWindowController()), config);
    display_impl = getFieldAsObject(Display.class, "display_impl");
    window = new Window(display_impl);

    timer.schedule(new TimerTask() {
        public void run() {
            window.showWindow(SW_HIDE); // hide the window

            // set as visible and then hide again to hide app from task bar
            window.setWindowLong(GWL_STYLE, User32.WS_POPUP | WS_VISIBLE);
            window.showWindow(SW_HIDE);

            window.setWindowLong(GWL_EXSTYLE, window.getWindowLong(GWL_EXSTYLE) | WS_EX_LAYERED | WS_EX_TOOLWINDOW | WS_EX_TOPMOST);
            window.setOpacity(255);

            isHidden = true;

            // Find the biggest resolution (assuming it's currently active)
            // TODO: do it before creating window, Gdx.graphics will not be available, so use JNA.
            DisplayMode[] modes = Gdx.graphics.getDisplayModes();
            DisplayMode biggestMode = modes[0];
            for (DisplayMode mode : modes) {
                if (mode.width > biggestMode.width && mode.height > biggestMode.height) {
                    biggestMode = mode;
                }
            }

            window.setSize(biggestMode.width, biggestMode.height/2);
        }
    }, 100);

    if (setVisibleOnStart) {
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                setVisible(true);
            }
        }, 1000);
    }
}
项目:libgdxcn    文件:JglfwApplicationConfiguration.java   
static public DisplayMode getDesktopDisplayMode () {
    java.awt.DisplayMode mode = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDisplayMode();
    return new JglfwDisplayMode(mode.getWidth(), mode.getHeight(), mode.getRefreshRate(), mode.getBitDepth());
}
项目:c2d-engine    文件:DefaultEngineCallback.java   
@Override
public void preLoad(DisplayMode mode, String[] assets) {
    for (final String path : assets) {
        Engine.getAliasResourceManager().load(path);
    }
}
项目:ingress-indonesia-dev    文件:AndroidGraphics.java   
public final Graphics.DisplayMode getDesktopDisplayMode()
{
  DisplayMetrics localDisplayMetrics = new DisplayMetrics();
  this.app.getWindowManager().getDefaultDisplay().getMetrics(localDisplayMetrics);
  return new AndroidGraphics.AndroidDisplayMode(this, localDisplayMetrics.widthPixels, localDisplayMetrics.heightPixels, 0, 0);
}
项目:ingress-indonesia-dev    文件:AndroidGraphics.java   
public final Graphics.DisplayMode[] getDisplayModes()
{
  Graphics.DisplayMode[] arrayOfDisplayMode = new Graphics.DisplayMode[1];
  arrayOfDisplayMode[0] = getDesktopDisplayMode();
  return arrayOfDisplayMode;
}
项目:ingress-indonesia-dev    文件:AndroidGraphics.java   
public final boolean setDisplayMode(Graphics.DisplayMode paramDisplayMode)
{
  return false;
}
项目:ChessGDX    文件:GraphicsSettings.java   
/**
 * @param displayMode
 *            LibGDX base DisplayMode
 */
private CustomDisplayMode(DisplayMode displayMode) {
    super(displayMode.width, displayMode.height, displayMode.refreshRate, displayMode.bitsPerPixel);
}
项目:c2d-engine    文件:EngineCallback.java   
void preLoad(DisplayMode mode, String[] assets);