Lwjgl3 : Gdx.graphics.setWindowedMode does not center the window
See original GitHub issueIssue details
Create a game with the below code (notice that setWindowedMode(1920, 1280) must be different value than the one in the Lwjgl3ApplicationConfiguration), make sure you are using Lwjgl3 desktop.
Toggling btween windowed mode and fullscreen (press ENTER) does not center the window. LwjglGraphics does not update the window position according to the new size but leaves it at it’s current position. Maybe this is wanted (I don’t believe it is though), but then please give the users a possibilty to center the window manually.
Reproduction steps/code
Sorry, for some reason github messes up the code formatting…
public class DesktopLauncher { public static void main(String[] arg) { new Lwjgl3Application(new TCTest(), new Lwjgl3ApplicationConfiguration()); } }
` public class TCTest extends ApplicationAdapter { SpriteBatch batch; Texture img;
@Override
public void create() {
batch = new SpriteBatch();
img = new Texture("badlogic.jpg");
}
@Override
public void render() {
if (com.badlogic.gdx.Gdx.input.isKeyJustPressed(Input.Keys.ENTER)) {
if (!Gdx.graphics.isFullscreen())
Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
else
Gdx.graphics.setWindowedMode(1920, 1280); // Depending on your supported screen resolutions use other values
}
Gdx.gl.glClearColor(1, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
batch.begin();
batch.draw(img, 0, 0);
batch.end();
}
@Override
public void dispose() {
batch.dispose();
img.dispose();
}
} `
Version of LibGDX and/or relevant dependencies
1.9.12-SNAPSHOT Lwjgl3 (it works fine with Lwjgl2)
Please select the affected platforms
- Android
- iOS (robovm)
- HTML/GWT
- Windows
- Linux
- MacOS
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (7 by maintainers)
Top GitHub Comments
I agree that it is not expected when leaving fullscreen and returning to the previous window size. However, when changing from fullscreen to a windowed screen size different than before, I think this should be treated like normal resizing, i.e. re-centering the window again.
I totally agree with @crykn