Hi,
I’d like to draw a funny windmill into a GlutWindow. I have set up two Viewports to project two diffent viewangels of the mill, and all looks fine. But only the second Viewport will draw correctly. I do not know why!
Here is a part of my coding:
void reshape (int w, int h)
{
int x = 0;
if (w<h)
x = (w/2);
else
if (w<(2*h))
x = (w/2);
else
x = h;
glViewport(0,0,(GLsizei)x, (GLsizei)x);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90.0,1.0,0.1,150);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0,10.0,zoom,
0.0,10.0,0.0,
0.0,1.0,0.0);
display();
glViewport(x + 5,1,(GLsizei)x, (GLsizei)x);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90.0,1.0,0.1,150);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0,10.0,zoom,
0.0,10.0,0.0,
0.0,1.0,0.0);
glRotatef(90, 0, 1, 0);
display();
}
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
and
glutSwapBuffers();
glFlush();
will called at the display()function.
Please help me to solve my mistakes
Thanks!