我是新手,很難理解glOrtho的概念。比如我有:麻煩理解glOrtho
void display(void)
{
/* clear all pixels */
glClear (GL_COLOR_BUFFER_BIT);
/* draw black polygon (rectangle) with corners at * (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0)
*/
glColor3f (0.0, 0.0, 0.0);
glBegin(GL_POLYGON);
glVertex3f (-.25,0,0.0);
glVertex3f (.25, 0, 0.0);
glVertex3f (.25, .25, 0.0);
glVertex3f (-.25, .25, 0.0);
glEnd();
/* don’t wait!
* start processing buffered OpenGL routines */
glFlush(); }
這就產生了一個矩形,然後這個「搖身一變」矩形:
void init (void)
/* this function sets the initial state */ {
/* select clearing (background) color to white */
glClearColor (1.0, 1.0, 1.0, 0.0);
/* initialize viewing values */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 1, 1, 0.0, -1.0,1.0);
}
,這幾乎使這方並提出在了在左上角。我不確定它是如何做到的。矩形中的點是否已轉換?編號: 想通了。這非常有幫助。 http://elvenware.sourceforge.net/OpenGLNotes.html#Ortho