PDA

View Full Version : similar glutPostRedisplay problem. Please Help!



02-06-2002, 04:27 AM
Hi, I am writing my very first openGL program and I am also having problem using glutPostRedisplay().

I have a list of points and I would like to draw one, clear screen, then draw next...

My debug code tells me that my displayFunc was called as many times as needed, but only the second point was actually drawn. Can anyone explain the cause?

Here is an excerpt of the code:

void NextPoint(void)
//this is called by glutIdleFunc
{

/*glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
DrawAxis();*/

if (pplus2){
//printf ("p-1 = (%f, %f), p = (%f, %f) p+1 = (%f %f), p+2 = (%f %f)\n", pminus1->x, pminus1->y, p->x, p->y, pplus1->x, pplus1->y, pplus2->x, pplus2->y);
currentPoint = pminus1;
glutPostRedisplay();

pminus1 = p;
p = pplus1;
pplus1 = pplus2;
pplus2 = pplus2->next;
}

//points = 0;
//CleanUp();
}

void glutDisplay(void)
{

float x, y;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

DrawAxis();

if (state == 0){
DrawPoints();
}

else{
x = currentPoint->x;
y = currentPoint->y;

printf("Got to glutDisplay!\nDrawing (%f, %f)\n", x, y);
glColor3f(1, 0, 0.5);
glBegin(GL_POINTS);
glVertex2f(x, y);
glEnd();
glFlush();
}

glutSwapBuffers();


}

thanks a bunch!

02-06-2002, 06:23 AM
nevermind... i figured it out... thanks for ignoring my post! http://www.opengl.org/discussion_boards/ubb/smile.gif