i am drawing a texture on a simple plane. The renderingcode is basically this:
gl.glEnableClientState(GL10.GL_VERTEX_ARRAY);
gl.glVertexPointer(3, GL10.GL_FLOAT, 0, _vertexBuffer);
gl.glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
gl.glTexCoordPointer(2, GL10.GL_FLOAT, 0, _textureBuffer);
gl.glDrawArrays(GL10.GL_TRIANGLES, 0, _vertexBuffer.capacity()/3);
With _vertextBuffer as
new float[] {
0, 0, 0,
0, height, 0,
widt开发者_运维知识库h, height, 0,
width, height, 0,
width, 0, 0,
0, 0, 0
};
where width and height are positiv values. _textureBuffer is
new float[] {
0, 0,
0, 1,
1, 1,
1, 1,
1, 0,
0, 0
}
With this the texture is turned around and mirrored or turned around 180 degrees. what am I doing wrong?
That's because the OpenGL texture coords convention is "upside-down" from normal conventions, to fix it, flip your t texture coords (0 -> 1, 1 -> 0).
精彩评论