I need some help . I am trying to display an object in multiple viewports, using an Orthographic persective to show different sides. I have four view ports, basically a window broken into four quads. Object being drawn is very simple: basically a cube made out of polygons. I can’t use the cube function because there is one extra face (slice).
Prior to drawing in each quad, I reset the viewport to a size a quarter of the screen, using the lower lefthand corner of my window as 0,0. I then call out an Ortho view, such that the view is a 4x4x4 cube (-2 to 2 in each direction). When I draw my front view, my cube is perfectly centered in the viewport (lower left hand quad). Note that in this quad, Z goes into and out of the screen. But when I draw one of the other views, my cube is offset in the Z direction by approximately 0.5 units in what appears to be the negative Z direction. I have tried for 5 hours to correct this, and cannot find anything that helps. I am including my code a code snippet to detail my issue. Any insight or guidance towards the light would be appreciated.
**Starts here, draws the Front View, then Top View **
// Enable depth testing
// Tell OpenGL which side of each face is the front facing face glFrontFace(GL_CCW); // Tell OpenGL to not apply some functions to faces that will be hidden glEnable(GL_CULL_FACE); // Redefine the viewport to the lower lefthand quadrant glViewport(0,0,iViewportWidth/2,iViewportHeight/2); //Setup the projection view and the coordinate system to display the view glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-2.0f, 2.0f, -2.0f, 2.0f, 2.0f, -2.0f); //Prepare to draw object in the view glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glPushMatrix(); myDrawPolygon(); glPopMatrix(); glFlush(); //Phase 3 - Show the block model's Top View in the upper left hand quandrant glClear(GL_DEPTH_BUFFER_BIT); // Redefine the viewport to the upper lefthand quadrant glViewport(0,iViewportHeight/2,iViewportWidth/2,iViewportHeight); //Setup the projection view and the coordinate system to display the view glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-2.0f, 2.0f, -2.0f, 2.0f, 2.0f, -2.0f); //Prepare to draw object in the view glMatrixMode(GL_MODELVIEW); glLoadIdentity(); //use this rotation to move position faces in Ortho views glPushMatrix(); glRotatef(90.0f, 1.0f, 0.0f, 0.0f); myDrawPolygon(); glPopMatrix(); glFlush();
[This message has been edited by torrey (edited 12-08-2000).]