Bit of a noob question methinks. I have a game with 2D and 3D stuff to draw. I’ve been doing this:
// setup 3D matrix
while (true) {
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glPushMatrix();
GL11.glLoadIdentity();
GL11.glOrtho(0, 480, 320, 0, 1, -1);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glPushMatrix();
GL11.glLoadIdentity();
// draw 2D stuff
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glPopMatrix();
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glPopMatrix();
// draw 3D stuff
}
Is this the right approach? Now I have the need to switch between drawing 2D and 3D stuff many times per frame, so that the graphics are layered correctly. What would the most efficient way to do this?