Hello Guest

mixing 2d & 3d

  • 2 Replies
  • 9666 Views
mixing 2d & 3d
« on: July 27, 2004, 19:40:48 »
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:

Code: [Select]

// 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

*

Offline princec

  • *****
  • 1898
    • Puppygames
mixing 2d & 3d
« Reply #1 on: July 27, 2004, 20:18:31 »
That's pretty much exactly the right way to do it.

Cas :)

mixing 2d & 3d
« Reply #2 on: July 27, 2004, 22:36:31 »
nice to hear  :D

thanks,

chris