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 2 of 2

Thread: newbie question regarding glClear

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2003
    Posts
    1

    newbie question regarding glClear

    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

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    May 2001
    Location
    France
    Posts
    768

    Re: newbie question regarding glClear

    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.

Posting Permissions

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