PDA

View Full Version : Works for frame 1, but then fails?



Sumdumguy
06-22-2008, 08:19 AM
I'm totally confused, this code executes properly for the first running, but then quits working. Originally it did work for all frames, but then quit and I can't figure out why! Since I'm new to opengl, I figure it's something I'm doing way wrong.

Hopefully someone can point me in the right direction. =)

Here's the offending code:


void BounceyBall::Draw()
{
glPushMatrix();
glTranslated(m_Location.X,m_Location.Y,m_Location. Z);
glRotated(60,1,0,0);
glRotated(m_Timer,0,0,1);
glutSolidSphere(m_Radius,10,10);
glPopMatrix();
}

What I did to "break" it...
originally it worked, but m_Radius was hard-coded at 1. I changed it to the soft coded value, and now the ball will neither spin nor move. The rotations and translations are completely ignored. I tried undoing it, going back to the hard coded value but it's still broke. =(
As near as I can tell, the code should work but doesn't.

It's called from here:


glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3d(1,0,0);

glPushMatrix();
glTranslated(0,0,-6);
VideoManager->ProcessFrame(t);
glPopMatrix();

... (Other test objects drawn, they work) ...

glutSwapBuffers();

Nicolai de Haan
06-23-2008, 03:11 AM
Maybe post more code. Try and make sure you have selected the modelview matrix and reset it (glLoadIdentity) before applying your transformations to the matrix in each frame.

sqrt[-1]
06-23-2008, 05:11 AM
What was said above, I am willing to be you are not resetting some state you changed.