I'm working on a libGDX (library on top of LWJGL) game project, and use the Intellij IDEA IDE from several different workstations:
I'm using the OpenJDK for Java 6 on the Ubuntu boxes, and Sun/Oracle Java 6 on the Windows box (I heard Java 6 was the one to use for Android compatibility).
When running on full-screen:
Looking into this further, I see that the calls to Gdx.graphics.getHeight() and Gdx.graphics.getWidth() return the size of the rectangle needed to cover both displays, in my case 3200x1080, but when I tell my game to run full-screen, it only uses one of the displays, so the cameras get set to 1920x1080, but my camera movement and Tiled map panning think they've got 3200x1080 to work with, making things distorted and unusable (since character can walk off of the screen to the right).
I'm guessing my problem actually comes from the sizes returned by the awt.Toolkit's getScreenSize() call, but I don't know how to interrogate it more deeply to get the size of the screen it will actually use when I go fullscreen.
My DesktopStarter gets the screen size and sets fullscreen as follows:
LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration(); Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize(); cfg.width = screenDimension.width; cfg.height = screenDimension.height; cfg.fullscreen = true; new LwjglApplication(new Game1(), cfg);
Is there a work-around to get the height/width of just the display that "full screen" will actually launch into?
So the trouble I'm seeing, is that executing the game.jar file, exiting the game, then executing again, repeatedly, results in different display modes showing up in the list of modes returned by Gdx.graphics.getDisplayModes() -- as P.T. pointed out below, this is a thin wrapper around LWJGL's Display.getAvailableDisplayModes()
. Why is this happening? Why would it be a different set of modes presented on subsequent runs on Ubuntu?
edit: per P.T.'s suggestion, put LWJGL references in question, since it seems to be LWJGL that's providing the list of display modes.
Thanks!
I would refrain from using Toolkit.getDefaultToolkit()
and use solely lwjgl.util.Display.getAvailableDisplayModes()
or the method described by libgdx.
Once you have set up a fullscreen window, fetch its size (if your set-up method doesn't already know that) and only use this information from thereon.
If Display.getAvailableDisplayModes()
changes its sort order on different executions, simply re-sort them and use the biggest one available or use a standard one and provide in-game settings to change them.
GraphicsDevice monitors[]=GraphicsEnvironment.getScreenDevices(); Dimension screen_resolution[monitors.length]; for (int monitorID = 0; monitorID < monitors.length; monitorID++) { screen_resolution[monitorID] = new Dimension(monitors[monitorID].getDisplyMode().getWidth(),monitors[monitorID].getDisplyMode().getHeight()); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With