Jump to content

  • Log In with Google      Sign In   
  • Create Account

Calling all IT Pros from Canada and Australia.. we need your help! Support our site by taking a quick sponsored surveyand win a chance at a $50 Amazon gift card. Click here to get started!


libgdx unwanted gaps btw tiles/objects


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 syskrank   Members   -  Reputation: 224

Like
0Likes
Like

Posted 04 September 2014 - 09:59 AM

Hey, everyone.

I've got a problem with using libgdx. I've packed all my images into POT atlas texture with 1024x1024 dimensions and loading it with the NEAREST filtering for mag and min.

 

From there I'm creating TextureRegions with NPOT-sizes ( which is OK, according to official libgdx wiki and OpenGL logics ) with sizes like 17x5, 69x69 and so on.

 

The actual problem is that when I move some graphical objects ( or tiles, if you will ), sometimes I see gaps between them, where no gaps should appear at all. Furthermore, the size of the gap differs through the time - it's seems to be frame-dependent or something.

 

I'm using standart libgdx' Screen class render( float delta ) method to organize my main cycle which is giving me 60FPS everytime. VirtualVM profiler says I'm doing pretty good with CPU and RAM - 10-20% on one core and 25Mb of RAM is used. So there's no possible lag, I suppose.

 

I really need help, because this thing is driving me crazy smile.png


Edited by syskrank, 04 September 2014 - 09:59 AM.


Sponsor:

#2 syskrank   Members   -  Reputation: 224

Like
0Likes
Like

Posted 05 September 2014 - 12:18 PM

Allright, after some digging and experiments here the complex solution:

 

To avoid gaps between objects or graphics entities in a libGDX application one should:

 

1. ensure to use floats everywhere - even for storing target screen resolution, to avoid unwanted casts and following precision loss; OpenGL is using floats for positioning, so should you;

 

2. use power-of-two textures: those with side sizes aliquot to 2^x - 32x32, 16x64, 128x256 and so on; doing so will satisfy the minimization of memory usage on GPU and will help to avoid texture coordinates distortions due to float-int casts, that may or may not happen whithin the rendering process ( whatch for your shaders and datatypes );

 

3. use POT textures even if documentation says that you can do the opposite; POTs are great;

 

4. try to use NEAREST filtering for loaded textures and texture atlases; this would protect you from wrong 'pixel mix', when OpenGL will try to average your color-filled pixels with transparent ones; however, for me that showed no significant results;

 

5. hit your artist smile.png ensure that all of your full-frame graphics elements have no transparent or half-transparent pixels at the edges - sith happens, you now smile.png

 

6.  use tight alignment and/or scale your objects just a little bit, so that they will overlay each other.

 

_____

Hope that would help someone. Cheers.


Edited by syskrank, 05 September 2014 - 03:16 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS