LibGDX - Desktop resolution problems

I’ve seen many topic talking about that kind of problem but I don’t know what is exactly mine. So, can you help me? I’m making a game with LibGDX for desktop. It’s a platformer where there is an OrtographicCamera(854, 480) and, LwjglApplicationConfiguration size (window size, I think) is the same, 854x480.

Here you have the game with standard resolution:

http://img829.imageshack.us/img829/8877/iold.png

Now, I change LwjglApplicationConfiguration resolution x2 (1708x960):

http://img138.imageshack.us/img138/4303/f3l0.png

Sprites look nice too but, when I use another resolution, x1.5 for example (1281x720):

http://img18.imageshack.us/img18/3091/285p.png

Pixels get crazy… there is a way in order to don’t deform textures (or smooth them) no matter what is the LwjglApplicationConfiguration size?

Use “Nearest” filtering.

When you load your textures you usually can supply TextureParameters:


// For example if you use an AssetManager
AssetManager manager = new AssetManager();

TextureParameters param = new TextureParameters();
param.minFilter = Texture.TextureFilter.Nearest;
param.magFilter = Texture.TextureFilter.Nearest;

manager.load("whatever.png", Texture.class, param);

In the resize() method, re-declare your orthographic camera with the new resolution.

matheus23: I tried use nearest filter but the result was the same. Then, I tried linear filter and:

http://img716.imageshack.us/img716/6313/1bwc.png

Linear gave me a nice result (I think nearest is the default filter). Thanks for your help ^^!!

netikan: But that will change the camera size, I want the camera has always the same size, window size is what I want to change.

If anybody knows other solutions feel free to tell me, please! But for now, Linear filter is doing a good job : D

Well, to actually explain what Nearest and Linear do:

When downscaling (or upscaling) Images, you can decide how the graphics card is going to do it:

When set to Nearest, the graphics card will simply look for the texel that is the nearest to the pixel it should be placed to.

When set to Linear, the graphics card will look at the surrounding texels and try to linearly interpolate the colors and set the pixel color to the computed color.

That’s why Linear appears smoother.
Though I thought that that’s not the effect you wanted to have. It looked like your game is a little more retro, and usually you use Nearest Filtering in retro games, since this is mostly how ‘retro’ games look.

Anyways, glad to help :slight_smile:

You was right. Nearest filter is what I was looking for but I dont want that textures get deformed. If I don’t find other way I think I’ll let use only two resolutions, 854x480 and 1708x960 (x2). After trying Linear filter in depth It gave me graphic errors like lines around textures…