Why can't I display same object in multiple viewports?
- by user288973
Hi,
I'm pretty new to OpenGL. Was playing around with some code but can't figure out why the following will not produce two viewports with the same object view. Heres the code:
glViewport(0, windowHeight/2, windowWidth/2, windowHeight);
glScissor(0, windowHeight/2, windowWidth/2, windowHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective( 45.0, (GLfloat)(windowWidth/2)/(GLfloat)(windowHeight/2), 0.1f,
500.0 );
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
drawParticleView();
glViewport(windowWidth/2, 0, windowWidth, windowHeight/2);
glScissor(windowWidth/2, 0, windowWidth, windowHeight/2);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective( 45.0, (GLfloat)(windowWidth/2)/(GLfloat)(windowHeight/2), 0.1f,
500.0 );
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
drawParticleView();
drawParticleView() just draws an array of rectangles. The problem is that the second viewport is a squashed representation of the first. My window width is 1280 and height 960. I'm obviously doing something wrong but what? Thanks