#StackBounty: #opengl #java #libgdx #lwjgl LibGDX Switching to fullscreen makes sprites blurry

Bounty: 100

I’m using LibGDX to develop/render my game and when I start the game in windowed mode, then switch to full screen, the sprites look blurry. Importantly(?), starting the game in full screen then switching to windowed mode doesn’t have this problem.

Here’s a section of a screenshot starting off windowed:

enter image description here

And after switching to fullscreen, the (roughly) same section of the screen:

enter image description here

The sprites are loaded from a TextureAtlas using LibGDX’s TexturePacker. They’re rendered using a normal SpriteBatch with the default settings/shaders.
These are my pack.json settings:

{
    "pot": true,
    "paddingX": 2,
    "paddingY": 2,
    "bleed": true,
    "edgePadding": true,
    "maxWidth": 4096,
    "maxHeight": 4096,
    "duplicatePadding": false,
    "filterMin": "MipMapLinearLinear",
    "filterMag": "Linear"
}

I wondered if the filterMin/Mag might be having some effect but trying different settings is giving the same results.

To switch between fullscreen and windowed, I’m using the following code:

public static void toggleFullscreen() {
    if (DisplaySettings.isGamefullscreen && Gdx.graphics.supportsDisplayModeChange()) {
        // Switch to windowed
        Gdx.graphics.setWindowedMode(DisplaySettings.windowedWidth, DisplaySettings.windowedHeight);
        DisplaySettings.isGamefullscreen = false;
    } else if (Gdx.graphics.supportsDisplayModeChange()) {
        // Switch to full screen
        Gdx.graphics.setWindowedMode(DisplaySettings.desktopWidth, DisplaySettings.desktopHeight);
        Gdx.graphics.setFullscreenMode(Gdx.graphics.getDisplayMode());
        DisplaySettings.isGamefullscreen = true;
    }
}

So in this case the game starts off windowed then toggles to fullscreen after everything has loaded/been set up.

I am using some FrameBuffers and TextureRegions to draw to, but these are disposed and recreated on a resize.

I feel like there’s some problems perhaps with the mipmaps being created and used incorrectly in this case but I’m a bit stuck at this point, any help much appreciated!


Get this bounty!!!