   glOrtho ... how to project?
  Hi everybody,I thought glOrtho is used to project stuff!?This is the first time I tried to implement gui rendering functionality ...and it doesn't work. How is glOrtho used properly?Can I stay in modelview mode? If I switch to projection mode nothing is drawn, if I stay in modelview mode the objects are not projected ... meaning if I use glTranslatef the objects get smaller/bigger.I know there was a tutorial at gametutorials.com ... but they are not free any more afaik.Is there a NeHe tutorial that covers projections?Or can somebody please post a brief code example that shows how to enter projection mode properly?   
  http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=17   ;  glOrtho is basically used to draw stuff in "2d". For instance, if you define two variables, width and height, you could use the following code to get into an ortho projection (at least this is how I do it)glDisable(GL_DEPTH_TEST);glDisable(GL_LIGHTING);glMatrixMode(GL_PROJECTION);glPushMatrix();glLoadIdentity();glOrtho(0,width,0,height,-1,1);glMatrixMode(GL_MODELVIEW);glPushMatrix();glLoadIdentity();now you can draw stuff between 0-width and 0-height on screen. If your polygons don't show up, try reversing the vertex order. To get back to normal life, you could then callglMatrixMode(GL_PROJECTION);glPopMatrix();glMatrixMode(GL_MODELVIEW);glPopMatrix();glEnable(GL_DEPTH_TEST);glEnable(GL_LIGHTING);;Quote:Original post by Cluelessif I stay in modelview mode the objects are not projected ... meaning if I use glTranslatef the objects get smaller/bigger.I don't understand what you are trying to say. Do you want your objects to get smaller/bigger or do you want them to stay the same size?If you want them to get smaller/bigger: Look into glFrustum/gluPerspective. In orthographic projections objects aren't supposed to get smaller/bigger.If you don't want that please post some code so we can see what is going wrong.;  Hi again,thanks for your replies. They helped!For the GUI I did not want the size to change ... but it did.I found out that I did not enter the projection mode properly in that case.The other problem still occured, though. The objects did not appear on the screen.I noticed that when I play with the far and near clipping plane values in the glOrtho function call the objects sometimes appear and sometimes they don't.Sometimes it does not really quite make sense to me.Guess unfortunately I'll have to stick with one setting that works without really understanding why it does.   ;Quote:Original post by CluelessI noticed that when I play with the far and near clipping plane values in the glOrtho function call the objects sometimes appear and sometimes they don't.Sometimes it does not really quite make sense to me.Guess unfortunately I'll have to stick with one setting that works without really understanding why it does.Most likely you are drawing your components outside the clipping planes. Since orthogonal is essentially 2d, just draw all ortho components with a z-value of 0. That's why we use -1 and 1 for the clipping planes. You can do this automatically by just calling glVertex2f() for your gui drawing.;  Crap!What confused me was that I thought by translating into the screen in an identity matrix:( glTranslatef(0.0f, 0.0f, -4.0f); )I'd end up at position 0.0f, 0.0f, -4.0f in the world matrix.So I set the far clipping to -5.0f instead of setting the near clipping plane to 5.0f.It did work when I was on the save side with both planes.Sorry 'bout that.No idea why I thought so.Probably because I am currently forcing myself to program and I can't concentrate enough.Thanks again!   