Android Open GL ES纹理问题

时间:2012-05-19 16:06:34

标签: android opengl-es

我遇到了一个问题,我认为可能与纹理坐标有关,下面的图片显示我的瓷砖地图正在渲染 - 但有时瓷砖之间会出现间隙,如下面网址的屏幕截图所示(屏幕中间有一段距离。

http://img15.imageshack.us/img15/4724/tileproblem.png

我的纹理区域声明为

public class TextureRegion {    
public final float u1, v1;
public final float u2, v2;
public final Texture texture;

public TextureRegion(Texture texture, float x, float y, float width, float height) {
    this.u1 = x / texture.width;
    this.v1 = y / texture.height;
    this.u2 = this.u1 + width / texture.width;
    this.v2 = this.v1 + height / texture.height;        
    this.texture = texture;
    }
}

图块纹理来自地图集,为32x32像素,我使用的是GL_Nearest

是Open GL的新手,我不太明白我需要改变什么。

纹理创建示例

tile = new TextureRegion(items, 192,160,34,34);

干杯

斯图尔特

1 个答案:

答案 0 :(得分:0)

确保纹理是基础2,例如128x256或512x512等。

相关问题