Hi. My program’s viewport seems to work on the width (ie when I resize the window, the box I drew does not move horizontally). However, when I resize the window it DOES move the object vertically. This makes me think that the viewport is somehow not correctly interpreting the height.
Here is my code if it helps:
#include <GL/glut.h>
GLsizei wh=600, ww=600;
void display(void)
{
//clear window
glClear(GL_COLOR_BUFFER_BIT);
//draw unit square polygon
glBegin(GL_POLYGON);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);
glEnd();
//flush GL buffers
glFlush();
}
void init()
{
//set bg color
glClearColor (0.695, 0.695, 0.934, 1.0);
//set fill color
glColor3f(1.0, 1.0, 1.0);
//this is the default view
glMatrixMode (GL_PROJECTION);
glLoadIdentity ();
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void myReshape(GLsizei w, GLsizei h)
{
}
void main(int argc, char** argv)
{
/* Initialize mode and open a window in upper left corner of screen /
/ Window title is name of program (arg[0]) */
glutInit(&argc,argv);
glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(wh,ww);
glutInitWindowPosition(20,40);
glutCreateWindow("A Sunny Day with Phil");
init();
glutReshapeFunc(myReshape);
glutDisplayFunc(display);
glutMainLoop();
}