I am learning opengl too. I faced this problem yesterday and I have not found the correct answer. Today, I have solve the problem. In my little program, the object changes size when resizing the window changing width or heigt. This is my code (please, forgive my errors):
#include <GL/freeglut.h>
void fnReshape(int ww, int hh)
{
GLdouble r;
if(hh == 0)
hh = 1.0;
if(hh > ww)
r = (double) hh / (double) ww;
else
r = (double) ww / (double) hh;
glViewport(0, 0, ww, hh);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(hh > ww)
glFrustum(-1.0, 1.0, -1.0 * r, 1.0 * r, 2.0, 200.0);
else
glFrustum(-1.0 * r, 1.0 * r, -1.0, 1.0, 2.0, 200.0);
}
//////////////////////////////////////////////////////////////////
void fnDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0., 0., -5.);
glBegin(GL_QUAD_STRIP);
glColor3f(0., 0., 1.0);
glVertex3f(-1., -1., 0.);
glVertex3f(-1., 1., 0.);
glVertex3f(1., -1., 0.);
glVertex3f(1., 1., 0.);
glEnd();
glutSwapBuffers();
}
////////////////////////////////////////////////////////////
int main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGBA |GLUT_DOUBLE);
glutInitWindowSize(500, 500);
glutCreateWindow("Sample window");
glClearColor(1.0, 0, 0, 1.0);
glutDisplayFunc(fnDisplay);
glutReshapeFunc(fnReshape);
glutMainLoop();
return 0;
}
glScissor()
. See this. – Submicroscopic