We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › Removing 3D transforms to draw in 2D
Page Index Toggle Pages: 1
Removing 3D transforms to draw in 2D? (Read 1210 times)
Removing 3D transforms to draw in 2D?
Nov 21st, 2006, 10:55pm
 
Hey guys, I'm running into a bit of trouble switching back to a 2D drawing mode for displaying high scores in this small web game I'm making, I'm rendering everything in 3D during the game and moving the camera, and I just want to reset the projection/camera etc, so I can use 2D functions and text like they normally should be able to be used if I hadn't used a projection matrix...

Anyways, here's a code snipit that I was currently playing around with to try and just display a list of scores... It just draws white though...

P.S. I can't seem to get the tabs working correctly on this board, =/ fortunately it's not too much code!

 public void DrawScores()
 {
   pushMatrix();
   
   camera();
   ortho(0, width, 0, height, -10, 10);
   
   background(255,255,255);
   image(back,0,0);
   
   for( int i=0; i<25; ++i )
   {
int value =    int(m_scores[i]);
if( value == m_currentScore )
fill(255);
else
fill(0);
text(str(value), 100, 30 + i * 24);
   }
   
   popMatrix();
 }
Re: Removing 3D transforms to draw in 2D?
Reply #1 - Dec 21st, 2006, 11:36pm
 
I use:
Beginning of my code:
import javax.media.opengl.*;

Where I need to draw 2D:
GL gl= ((PGraphicsOpenGL)g).gl;
gl.glDepthFunc(javax.media.opengl.GL.GL_ALWAYS); //turn off Z buffering
camera(); //reset the camera

//Draw 2D stuff here

gl.glDepthFunc(javax.media.opengl.GL.GL_LESS); //turn it back on
Re: Removing 3D transforms to draw in 2D?
Reply #2 - Dec 22nd, 2006, 3:41pm
 
does hint(DISABLE_DEPTH_TEST) not work? that's what it's for, so if not that would be a bug and maybe we should use joseph's method instead.
Page Index Toggle Pages: 1