where could this go wrong? *eep*

Started by
5 comments, last by rileyriley 23 years, 3 months ago
The following function gets called once each time a frame is rendered. I have positively confirmed that with cout statements. void KamikazeEnemyShip::draw() {      cout << "DRAWING KAMIKAZE SHIP: (" << xPos << ", " << yPos << ", " << zPos << ")\n" << flush;      glMatrixMode(GL_MODELVIEW);      glPushMatrix();      glLoadIdentity();      glBegin(GL_TRIANGLES);          glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, norm_blue_diffs);          glVertex3f(-.5, 0, 0);          glVertex3f(.5, 0, 0);          glVertex3f(0, -1, 0);      glEnd();      glPopMatrix(); } the frustrating part is that this draws a blue triangle exactly one time. Then it never gets drawn (on the visible portion of the screen, anyway) again. My whole program is way to big to post, but does anyone have any suggestions about where to look for a bug? I have checked all of my glPushMatrix calls and they are all matched by a corresponding PopMatrix call, in the same matrix mode. That was my only idea. norm_blue_diffs is a diffuse material property array, and it is never changed. It''s never even accessed anywhere but here, for that matter. Also, lighting is enabled, but even when I turn it off and change that material call to a glColor call I have the same problem. Thanks for any help /riley
--Riley
Advertisement
Try moving your triangle a step in the scene. My guess is that you want what you get after removing the glLoadIdentity.
I''m surprised that even shows it once -- it shouldn''t show it at all. Change the Z-Value to -1 instead. 0 is right where the camera is, so in essence the triangle is right inside of you .
ah, sorry -

I forgot to mention that the function that calls all of the drawing routines calls
gluLookAt(0.0, 0.0, 20, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
immediately before them. So I draw most things on z=0 and everything BUT this shows up correctly.

Btw, my other drawing routines are exactly the same as this one. The only difference is that they call glTranslate3f(xPos, yPos, zPos) and draw different shapes w/ different colors. Ok fine they're completely different but the _structure_ is the same. Push and Pop calls are all in corresponding places, etc. Makes it all the more confusing why this one doesn't work.

Edited by - rileyriley on January 12, 2001 10:24:31 PM
--Riley
Your call to glLoadIdentity makes the glulookAt call useless.
true
gluLookAt(0.0, 0.0, 20, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
glLoadIdentity();

aint good try

first this
glLoadIdentity();
gluLookAt(0.0, 0.1, 20, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
drawShip();

///
drawShip()
{
glPushMatrix();
glBegin(GL_TRIANGLES);
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, norm_blue_diffs);
glVertex3f(-.5, 0, 0);
glVertex3f(.5, 0, 0);
glVertex3f(0, -1, 0);
glEnd();

glPopMatrix();
}





http://members.xoom.com/myBollux
ohhhhhhhh

thanks a lot - that definitely was the problem.

I thought that the gluLookAt messed with the projection matrix, and that the loadIdentity worked for the model view matrix (I was in model view mode). I guess gluLookAt actually just simulates a camera by transforming all the vertices around.

thanks again!
/riley
--Riley

This topic is closed to new replies.

Advertisement