Sign in to follow this  
Wibbs

[libgdx] Black screen when toggling from fullscreen to windowed mode

Recommended Posts

Hey all,

 

I have just started working with libgdx, and have run into my first problem. I have a simple program that switches a desktop application from windowed mode to fullscreen and back again. If I start the program in windowed mode, it initially displays fine. When I toggle to full screen it is also OK.

 

However, when I toggle back to windowed mode the screen goes completely black. The application remains responsive though, and if I toggle again it will go back to fullscreen and display correctly.

 

I am using 64-bit Windows 7 with the IntelliJ IDEA IDE.

 

Any help with working out why it is doing this would be greatly appreciated.

 

A minimal example that displays the issue is shown below:

 

 

public class MyGdxGame extends ApplicationAdapter {

@Override
public void create () {	
	fullScreen = false;
}

@Override
public void render () {
	Gdx.gl.glClearColor(1, 0, 0, 1);
	Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

	if (Gdx.input.isKeyPressed(Input.Keys.TAB)) {
		fullScreen = !fullScreen;
		DisplayMode currentMode = Gdx.graphics.getDesktopDisplayMode();
		Gdx.graphics.setDisplayMode(currentMode.width, currentMode.height, fullScreen);
	}
}

private boolean fullScreen;
}


Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this