Advertisement

projection matrices help!

Started by May 09, 2003 05:54 PM
1 comment, last by lisaG 21 years, 9 months ago
Hi, just wondering if anyone can help me. I''m kinda new to OpenGL, and I can''t get my head round projection matrices. How do I do a simple thing like set up ortho projection so the window coords go from, say, 0 - 10 up and down and left to right, starting from the bottom left corner? I tried to view a simple triangle with coords 1,1,0,0,0,0,1,0,0, and you can see it in persp view, but when I change to ortho view it disappears. I''ve tried messing around with the values, but nothing seems to work. Heeeeeelp pleeeeeeeeeease!!
Ok, if you want 0-10 with 0 in the bottom left:

glMatrixMode(GL_PROJECTION);
glOrtho( 0.0, 10.0, 0.0, 10.0, -9999.0, 9999.0 );

---

glOrtho( left, right, bottom, top, near, far )

glOrtho sets up the matrix so point (left,bottom) on the near plane is mapped to the bottom left point in your viewport and (right,top) is mapped to the top right.

---

If you have a triangle defined by:

glVertex3f(1,1,0);
glVertex3f(0,0,0);
glVertex3f(1,0,0);

And your MODELVIEW matrix is identity, the triangle should appear in the bottom left of your viewport.


[edited by - JuNC on May 10, 2003 5:30:50 AM]
Advertisement
have a look at nehe''s lesson 21, it does some ortho drawing
don''t piss on an electrical fence

This topic is closed to new replies.

Advertisement