I was trying to understand the gluOrtho2D function. I have drawn 4 lines originating from the center reaching up to 4 corners of the screen.
You can follow the below code. osize is a variable which is used to set the parameters of gluOrtho2D. It will create a window of size 2*osize.
If works fine when osize is 1. Lines reach the corners. But as I increase the value of osize, the length of the lines decreases (cross becomes smaller and does not cover the whole screen). But I think it should reach the corner.
void display()
{
glClear( GL_COLOR_BUFFER_BIT );
//glViewport(0, 0, 100, 100);
glMatrixMode (GL_PROJECTION);
float osize = 1.2;
//glOrtho(-osize*1.0, osize*1.0, osize*1.0, -osize*1.0, -1.0, 1.0);
gluOrtho2D(-osize*1.0, osize*1.0, osize*1.0, -osize*1.0);
glMatrixMode (GL_MODELVIEW);
glBegin(GL_LINES);
glColor3f(0.0, 0.0, 1.0);
glVertex2f(0.0, 0.0);
glVertex2f(-osize*1.0, -osize*1.0);
glVertex2f(0.0, 0.0);
glVertex2f(-osize*1.0, osize*1.0);
glVertex2f(0.0, 0.0);
glVertex2f(osize*1.0, -osize*1.0);
glVertex2f(0.0, 0.0);
glVertex2f(osize*1.0, osize*1.0);
glEnd();
glutSwapBuffers(); //includes glFlush();
}
What is the problem?