• Advertisement

Archived

This topic is now archived and is closed to further replies.

where could this go wrong? *eep*

This topic is 6247 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Try moving your triangle a step in the scene. My guess is that you want what you get after removing the glLoadIdentity.

Share this post


Link to post
Share on other sites
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 .

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Your call to glLoadIdentity makes the glulookAt call useless.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement