mclz522
08-29-2009, 06:21 PM
Hi all!
I'm trying to make an application to do path simulation and show the moving point animation. Basically, I have a set of ordered points that are pre-calculated and I want to show this path to a user. Currently My code is like following
int total = points.size();
int current = 0;
for(int current = 0;current<total;current++)
{
glBegin(GL_LINES);
glColor3f(1.0f, 0.0f, 0.0f);
for(int i = 0; i<current; i++)
{
glVertex3f(points[i].x,points[i].y,points[i].z);
}
glEnd();
glutPostRedisplay(); //repaint the display
glFlush();
glutSwapBuffers();
}
As you can see, it repaints for every new point and the user can see a moving point. However, it works fine for small number of points. If I have a large number of points (eg 10 million), it becomes very slow at the end.
If I dont repaint previous points, everything disappears. Is there anyway to persist what I have drawn on the screen?
Thank you
I'm trying to make an application to do path simulation and show the moving point animation. Basically, I have a set of ordered points that are pre-calculated and I want to show this path to a user. Currently My code is like following
int total = points.size();
int current = 0;
for(int current = 0;current<total;current++)
{
glBegin(GL_LINES);
glColor3f(1.0f, 0.0f, 0.0f);
for(int i = 0; i<current; i++)
{
glVertex3f(points[i].x,points[i].y,points[i].z);
}
glEnd();
glutPostRedisplay(); //repaint the display
glFlush();
glutSwapBuffers();
}
As you can see, it repaints for every new point and the user can see a moving point. However, it works fine for small number of points. If I have a large number of points (eg 10 million), it becomes very slow at the end.
If I dont repaint previous points, everything disappears. Is there anyway to persist what I have drawn on the screen?
Thank you