简体   繁体   English

LibGdx怪异的纹理行为

[英]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. 在原始纹理中,每行的宽度为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. 在渲染的纹理中,顶线似乎从顶部消失,并移动到底部,有效地形成了2px的线。 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. 似乎在尝试使用小数点位置绘制纹理时发生这种情况(在我的情况下为x = 580.5),要对其进行修复,我必须使用Math.round()来确保它是一个整数。

I thought that LibGdx and/or opengl was capable of rendering with subpixel precision. 我认为LibGdx和/或opengl能够以亚像素精度进行渲染。 Weird. 奇怪的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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