I’m a new openGL programmer trying to understand why certain things are happening with my glOrtho call, and what is actually happening when I call certain things. Specifically, why my GL_LINES show up sometimes and don’t show up others.
In my init() function for GL, I set up my viewport to be 640x480, disable lighting, and a few other things. In my paint() function, I do a glOrtho call:
glOrtho(0.0f, 640.0f, 0.0f, 480.0f, 0.0f, 1.0f);
Here’s my question: if I do a glBegin(GL_LINES) and draw lines BEFORE my projection, I have to draw them on the ([0,1],[0,1]) scale, e.g.
glColor4f(1.0, 0.0, 0.0, 1.0); glLineWidth(5.0); glBegin( GL_LINES ); glVertex2f(0, 0); glVertex2f(0, 1); glEnd();
BUT, if I call it AFTER I do my ortho projection, I draw them on the full ([0,640],[0,480]) scale, e.g.
glColor4f(1.0, 0.0, 0.0, 1.0); glLineWidth(5.0); glBegin( GL_LINES ); glVertex2f(100, 100); glVertex2f(200, 200); glEnd();
My question is: I thought that everything was relational, so that if I drew a 2D line from 0,0 to 100,100, it would be drawn in some model frame, so that when I did my glOrtho that set my projection to 640x480, it would appear going from 0,0 to 100,100. However, this is not the case.
Can anybody help me understand why/how this is working?