Android OpenGL es "glDrawTexfOES" draws upside down
Posted
by
Alle
on Stack Overflow
See other posts from Stack Overflow
or by Alle
Published on 2012-04-02T23:09:53Z
Indexed on
2012/04/02
23:30 UTC
Read the original article
Hit count: 201
I'm using OpenGL for Android to draw my 2D images.
Whenever I draw something using the code:
gl.glViewport(aspectRatioOffset, 0, screenWidth, screenHeight);
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glLoadIdentity();
GLU.gluOrtho2D(gl, aspectRatioOffset, screenWidth + aspectRatioOffset,screenHeight, 0);
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glLoadIdentity();
gl.glEnable(GL10.GL_TEXTURE_2D);
gl.glBindTexture(GL10.GL_TEXTURE_2D, myScene.neededGraphics.get(ID).get(animationID).get(animationIndex));
crop[0] = 0;
crop[1] = 0;
crop[2] = width;
crop[3] = height;
((GL11Ext)gl).glDrawTexfOES(x, y, z, width, height)
I get an upside down result. I'v seen people solve this through doing:
crop[0] = 0;
crop[1] = height;
crop[2] = width;
crop[3] = -height;
This does however hurt the logic in my application, so I would like the result to not be flipped upside down. Does anyone know why it happen, and any way of avoiding or solving it?
© Stack Overflow or respective owner