LWJGL
May 23, 2012, 04:06:30 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.8.3 released!
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: mixing 2d & 3d  (Read 3718 times)
chriddel
Newbie
*
Posts: 27


WWW
« on: July 27, 2004, 12: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 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
Logged
princec
Nerdus Imperius
*****
Posts: 1782



WWW
« Reply #1 on: July 27, 2004, 13:18:31 »

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

Cas Smiley
Logged

chriddel
Newbie
*
Posts: 27


WWW
« Reply #2 on: July 27, 2004, 15:36:31 »

nice to hear  Cheesy

thanks,

chris
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!