Main Menu

mixing 2d & 3d

Started by chriddel, July 27, 2004, 19:40:48

Previous topic - Next topic

chriddel

Hello everybody,

for our slot machine game we are mixing 3d and 2d elements. the wheels are 3d so we have some nice perspective and light effects. the game interface that is always visible above the wheels is 2d.

this is the main rendering function:

// Select The Projection Matrix
GL11.glMatrixMode(GL11.GL_PROJECTION); 
// Reset The Projection Matrix
GL11.glLoadIdentity(); 
// Calculate The Aspect Ratio Of The Window
GLU.gluPerspective(45.0f, (float) Display.getWidth() / (float) Display.getHeight(),0.1f,100.0f);
GL11.glEnable(GL11.GL_DEPTH_TEST); // Enables Depth Testing
//now render the wheels
wheels.render();

// Select The Projection Matrix
GL11.glMatrixMode(GL11.GL_PROJECTION); 
// Reset The Projection Matrix
GL11.glLoadIdentity(); 
//Projection for 2d to adress pixel by x,y
GL11.glOrtho(0, width, height, 0, -1, 1);
// Select The Modelview Matrix
GL11.glMatrixMode(GL11.GL_MODELVIEW); 
GL11.glDisable(GL11.GL_DEPTH_TEST);
interface.render();


so in every rendering loop we change the projection 2 times.
it works fine... but we are not sure if this is a very good way to do it  :?  

Anybody has a suggestion?  :idea:

Thanks,

Chris

princec

That's pretty much exactly the right way to do it.

Cas :)

chriddel

nice to hear  :D

thanks,

chris