PDA

View Full Version : newbie question regarding glClear



surya24
08-12-2003, 11:21 PM
Hi,
I'm a newbie to opengl, trying to write a code,
where i've 2 objects circle and a point. as the circle moves, the point traces a curve. when i use a function to move the circle, i've to always give
glClear (GL_COLOR_BUFFER_BIT) , which erases the current scene in on the window, and draws the scene completely again. but when i want to trace a curve, with respect to the movement of the circle, i cannot use glClear, as it will erase, the curve, drawn in the previous iteration. how can i avoid this. I want to trace the curve, along with the movement of circle.

Thanks in advance,
Surya

vincoof
08-12-2003, 11:45 PM
You have to trace your curve again and again everytime as well as the circle, even if the curve does not move.

void render(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
/* render curve here */
glTranslatef(/* circle movement here */);
/* render circe here */
}

And if the curve is very long to render (e.g. millions of vertices) you may render your curve, grab the picture into a texture, and then render a simple quad with that texture over it, to simulate the presence of the curve. It's a bit complex to setup, though, so you may do it only if you need better performance.