Texture issue with drawing triangles with OpenGL for Android
i have written code for draw a triangle and rectangle.
// Reset the Modelview Matrix
gl.glLoadIdentity();
gl.glTranslatef(0.0f, -1.2f, -6.0f);
tt.draw(gl); //rectangle class draw method
gl.glTranslatef(0.0f, 2.5f, 0.0f);
tr.draw(gl); //triangle class draw method
i have load a texture on rectangle
// Load the texture for the rectangle in onSurfaceCreated()
tt.loadGLTexture(gl, this.context);
my problem is开发者_运维知识库 the texture mapping on triangle shape also the screen shot is available in following link. http://www.freeimagehosting.net/uploads/82fe919770.png
how can i resolve this problem?
It seems like this would be a fairly simple problem to fix, and I don't believe it's Android specific... Are you defining the UV Texture Coordinates for your object? If you don't, OpenGL will not display the texture properly. You can use either the glTexCoord3f function in immediate mode, or glTexCoordPointer if you're using C arrays.
精彩评论