2
\$\begingroup\$

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!

\$\endgroup\$
0

1 Answer 1

3
+100
\$\begingroup\$

The problem is that you started the game with a specific resolution Width x Height. Next you tell you application to render that on the fullscreen, so it is taking that rendering and upscaling it, which causes you rendering to look blurry.

What you have to do is to call this first in your function: Gdx.graphics.setDisplayMode(x_width, y_width, DisplaySettings.isGamefullscreen), where x_width and y_width is the size you actually want the image rendered in (not upscaled to).

Then you might also have to send the new x_width and y_width to the camera, including updating the camera.

Hope that helps you.

\$\endgroup\$
2
  • \$\begingroup\$ That does help, thank you. Is there a way to set this scaling after the game has started, or will I always have to start at the desktop/monitor resolution and then scale down from there? \$\endgroup\$ Commented Mar 13, 2017 at 20:56
  • \$\begingroup\$ Keep in mind I am not used to libGDX, I did just recongnize the problem. It seems to that you have to call Gdx.graphics.setDisplayMode(x_width, y_width, DisplaySettings.isGamefullscreen) before calling setWindowedMode (in your posted function). Possibly even uptading the camera with new width and height. There is also one possibility that your textures are too low resolution, in which case there is not much to do about it other than getting higher resolution textures. \$\endgroup\$ Commented Mar 14, 2017 at 3:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .