I am confused with something that is occuring in my viewport. Here is my code and I will explain my confusion after the code:
glViewport( (GLsizei) ( width * 5 / 7 ), (GLsizei) ( 0 ), (GLsizei) ( width * 2 / 7 ), (GLsizei) ( height ) );
glLoadIdentity( );
glOrtho( (GLfloat) ( width * 5 / 7 ), (GLfloat) width, 0.0, (GLfloat) height, -2.0, 2.0 );
glColor3f( 0.0, 0.0, 0.0 );
glBegin( GL_LINES );
glVertex2f( ( width * 4 / 7 ), -height / 2 );
glVertex2f( ( width * 4 / 7 ), 3 * height / 2 );
glVertex2f( ( width * 5 / 7 ), ( 0 ) );
glVertex2f( ( width * 5 / 7 ), ( height ) );
glVertex2f( ( width * 6 / 7 ), ( 0 ) );
glVertex2f( ( width * 6 / 7 ), ( height ) );
glEnd( );
I am trying to draw 3 lines in the left 2/7 of the screen, which is its own viewport as can be seen. The first line I want to run down the entire length of the screen on the left edge of the viewport. I would have thought my x-coord would be (width * 5 /7 ) but I have to use 4/7 to get it to work. Then I want the line to run the entire width so I thought it would go from 0 to height, but instead it runs from -height/2 to 3height/2. And the last 2 lines I want to go down the middle half of the viewport so I would have thought from 3height/4 to height/4 but no, its from 0 to height. height is equal glutGet( GLUT_WINDOW_HEIGHT ); and width is equal to glutGet( GLUT_WINDOW_WIDTH );. For some reason height prints out as 0 and width as 1082081280 even though I set the window initially to a width of 700 and height of 500. So this may be a problem more than my code thinking. Any advice on why this doesn’t work the way I think it should would be apprectiated! Thanks!