简体   繁体   中英

LibGdx weird texture behaviour

So I am trying to render a sprite with this texture:

应该看起来如何

However, it renders like this:

看起来如何

In the original texture, every line has a width of 1px. In the rendered texture,the top line seems to have dissapeared from the top and moved to the bottom effectively forming a 2px line. The texture is loaded from a single file, not a sheet.

I have disabled/enabled texture filtering, it did not help.

I have made sure the camera is not zoomed in or out.

I have made sure the texture is not scaled in any way.

I haven't specified any wrap for the texture.

Any ideas as to what may be causing this?

I figured it out!

Seems that this occurs when trying to draw the texture at position with decimals (in my case it was x=580.5), to fix it I had to use Math.round() to ensure that it was a full number.

I thought that LibGdx and/or opengl was capable of rendering with subpixel precision. Weird.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM