Hi,
I have a problem with defining the “world” on opengl. As far as I understand glViewport is the “camera” in my world, and gluPerspective defines that world. Now please look at this code:
void RenderScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBegin(GL_QUADS);
glColor3f(0.0f, 1.0f, 0.0f);
glVertex3f(0,0,0);
glVertex3f(10,0,0);
glVertex3f(10,10,0);
glVertex3f(0,10,0);
glColor3f(1.0f, 1.0f, 0.0f);
glVertex3f(10,0,-10);
glVertex3f(10,10,-10);
glVertex3f(10,10,0);
glVertex3f(10,0,0);
glColor3f(0.0f, 0.0f, 1.0f);
glVertex3f(0,0,0);
glVertex3f(0,0,-10);
glVertex3f(0,10,-10);
glVertex3f(0,10,0);
glColor3f(0.0f, 1.0f, 1.0f);
glVertex3f(10,10,-10);
glVertex3f(0,10,-10);
glVertex3f(0,0,-10);
glVertex3f(10,0,-10);
glEnd();
glFlush();
}
and:
void ChangeSize(int w, int h)
{
glViewport(0,0,w/2,h/2);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0f, (GLfloat)(w/h), 0, 100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRotatef(20, 1,1,1);
}
The object is clipped at the top, so I guess my world is not “big” enough. But how do I, say, increase its width in the x and y axis?
I’m using VC6 with NVIDIA Drivers, OGL 1.2 + GLUT.