how to solve the pixel problem

Anything libgdx related goes here!

how to solve the pixel problem

Postby TruePlayer » Tue Sep 10, 2019 9:33 pm

I created a viewPort 320x480 this works, but when my application launches on higher resolution screens, I get a pixel image. Not only sprites, but also buttons and other UI elements.
How is this solved?
TruePlayer
 
Posts: 103
Joined: Sun Jul 28, 2019 12:22 pm

Re: how to solve the pixel problem

Postby tenfour04 » Wed Sep 11, 2019 1:52 am

It is good practice to use a separate viewport for the UI. Either a ScreenViewport (but then you need to provide UI assets at multiple resolutions and pick one to use at runtime) or use an ExtendViewport with large dimensions and make your UI atlas (MipMapLinearLinear, Linear).

The second option is much easier but carries a performance impact for the trilinear filtering.
tenfour04
 
Posts: 1233
Joined: Sat Jun 18, 2011 3:24 pm

Re: how to solve the pixel problem

Postby TruePlayer » Wed Sep 11, 2019 9:26 am

is there any detailed article about this somewhere?
TruePlayer
 
Posts: 103
Joined: Sun Jul 28, 2019 12:22 pm

Re: how to solve the pixel problem

Postby nnaass » Wed Sep 11, 2019 10:47 am

What we do is to create a helper methods to set relative size. if your basic size is 320x480 (this what you see in development),

then you create a class i.e. View.get() this class will get the current Graphics size and set some factor in relation to 320x480

So you need to have an image that is 50px X 50px

img.setSize(View.get().getRelativeSize(50),View.get().getRelativeSize(50));

the "img" will always be sized in relation to Graphics size

Hope that helps
nnaass
 
Posts: 61
Joined: Sat Jan 25, 2014 4:44 pm

Re: how to solve the pixel problem

Postby TruePlayer » Wed Sep 11, 2019 8:09 pm

OK, with IMG I understood, but what about the button skin?
TruePlayer
 
Posts: 103
Joined: Sun Jul 28, 2019 12:22 pm

Re: how to solve the pixel problem

Postby nnaass » Thu Sep 12, 2019 10:32 pm

Skin is tricky , the way we do it, is to have 4 skins and load this according to device resolution.

You have to make your own assets loader and load the correct skin
nnaass
 
Posts: 61
Joined: Sat Jan 25, 2014 4:44 pm

Re: how to solve the pixel problem

Postby errorbuffed » Mon Sep 16, 2019 8:21 am

The second option is much easier but carries a performance impact for the trilinear filtering.
Update gun mayhem 2 online.
errorbuffed
 
Posts: 1
Joined: Mon Sep 16, 2019 8:18 am


Return to Libgdx

Who is online

Users browsing this forum: MSN [Bot] and 1 guest