Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: How to simulate path with large number of points

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2009
    Posts
    10

    How to simulate path with large number of points

    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

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: How to simulate path with large number of points

    Using immediate commands such as glVertex3f is very costly, so completely unsuitable for millions of points.

    For much better performance, try with VBO :
    http://www.opengl.org/wiki/VBO
    http://www.opengl.org/wiki/VBO_-_more

    You can try to split the point cloud in chunks, with static points separated from dynamic points (less vbo updates to be done).

    Redrawing everything is the classic way of doing hardware-accelerated computer graphics.
    If you have a static camera however, there are tricks such as draw framebuffer once (with all static points), copy it to a texture, then for all other frames, draw a full size texture quad + the moving points. It may or may not be faster.

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2009
    Posts
    10

    Re: How to simulate path with large number of points

    Hi Zbuffer!
    Thank you for your advice.
    I will try it out.

  4. #4
    Junior Member Newbie
    Join Date
    Aug 2009
    Posts
    6

    Re: How to simulate path with large number of points

    Hi mclz522,

    you are already drawing line segments, so you could also try to simplify the geometry by leaving out points that are on or close to a line segment anyway. If your curve doesn't change, you only need to do that once.

    There's a simple recursive subdivision scheme. According to wikipedia, it's called the "Ramer-Douglas-Peucker" algorithm. Funny, I never knew it actually had a fancy name

    Here's the link: http://en.wikipedia.org/wiki/Ramer-D...cker_algorithm
    -Kolja

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •