I myself wouldn't do this every frame. I would have both the 3D and 2D
projection matrices cached someplace and bang it in with glLoadMatrix
each frame. You likely are using these for culling and other stuff
anyways. I wouldn't bother with push/pop but in reality it's likely a
very small performance difference.
Leigh
On 6/20/2010 5:10 PM, Simone wrote:
Hi, I created a 3D world, and I managed to draw 2D overlay controls
(as in a game) over it.
I did it with this:
public void onDrawFrame(GL10 gl) {
//some 3d draws and transformations here
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glPushMatrix();
gl.glLoadIdentity();
GLU.gluOrtho2D(gl, 0, WIDTH, 0, HEIGHT);
gl.glMatrixMode(GL10.GL_MODELVIEW);
gl.glPushMatrix();
gl.glLoadIdentity();
square1.draw(gl);
square2.draw(gl);
gl.glPopMatrix();
gl.glMatrixMode(GL10.GL_PROJECTION);
gl.glPopMatrix();
gl.glMatrixMode(GL10.GL_MODELVIEW);
...
}
Since I don't like it one bit, is there a more efficent (and elegant)
way to do it?
Thanks
Simone
--
Leigh McRae
www.lonedwarfgames.com
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en