PDA

View Full Version : my display func only draws once



topekk
02-01-2004, 11:21 PM
void myDisplay(void)
{

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);


/* ortho projection in left pane */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

glViewport(0,0,xMax/2,yMax);
glOrtho(-1.0,1.0,-1.0,1.0,-1.0,1.0);


gluLookAt(v1x0,v1y0,v1z0,v1xref,v1yref,v1zref,v1Vx ,v1Vy,v1Vz);

glMatrixMode(GL_MODELVIEW);


glDisable(GL_DEPTH_TEST);
glDisable(GL_CULL_FACE);
glPushMatrix();
drawXYZ();
glPopMatrix();

glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);

glPolygonMode(GL_FRONT, GL_LINE);
glClearDepth(5.0);


draw3DObject();

/*perspective view in right pane */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(xMax/2,0,xMax, yMax);
gluPerspective(45.0, 1, 1.0, 4.5); //(xMax/2.0) / yMax

//glTranslatef(0.0,0.0,-4.5);
//glTranslatef(-1.0,0.0,0.0);
glMatrixMode(GL_MODELVIEW);
iHateTrig(&pX, &pY, &pZ, pXRot, pYRot, pRad);
gluLookAt(pX,pY,pZ ,0,0, 0,v1Vx,v1Vy,v1Vz);

draw3DObject();

glutSwapBuffers();


}

dorbie
02-01-2004, 11:38 PM
You keep multiplying glulookat matrices on the modelview with no push pop, right ath the end, and no load identity on the modelview so it's not surprising you don't see anything after the first rendering.

dvm
02-02-2004, 12:31 AM
I think the problem is simpler (once you've been there your self a couple of times). Do you call glutPostRedisplay? After you draw each frame not only do you have to swap the buffers but tell glut that the display needs to be redrawn. A good place for it would be right under glutSwapBuffers();

topekk
02-02-2004, 05:29 AM
First off thankyou very much because adding the load Identity did work (well it displays at least but the output is problematic-back to the drawing board!)

I haven't seen enough details in tutorial or text about when to push/pop matrix Could you give me some insights into when they are needed?

McWare
02-02-2004, 05:33 AM
The best analogy for Push/Pop is:

glPushMatrix() - Remember where I am

glPopMatrix() - Return to where I was

This applies for both model and projection. So if you are drawing multiple objects in a scene, you remember where you are (push), move to the new location, draw your stuff, and return to where you were (pop), then continue on.

With Projection, if you have multiple viewports or something along those lines, or are drawing 2d text on the screen, you want to remember your screen settings (push), setup your new view, draw the new stuff, and return to the old view (pop)

Hope that helps.