View Full Version : Display Buffer.

01-22-2003, 12:41 AM
I am running some sort of simulation. in which i am generated some spheres in random co-ordinates. later i am doing some transformation with that sphere by adjusting the radius and translating to different place.

When then time moves by i am generating another sphere in new location. The location is found using some random number generation of the coordinates.

I'm calling a TimerFunc() of every 33ms. When the number of frames increases the number of spheres also increased and the animation of particular sphere is done in every frame.

I am calling RenderScene() callback function to display this.

When i use the glutSwapBuffers() r glutPostRedisplay(), I'm losing the previous sphere which was already displayed and animated.

How to retain those spheres with respect to frame rate, Lets say 30fps. If i am running this simulation the sphere has to appear with respect to time and the animation of eat frame has to take place subsequently, i.e., any animation on the sphere.

Please help me how to solve this situation.

Riaz. http://www.opengl.org/discussion_boards/ubb/smile.gif

01-22-2003, 01:27 AM
As long as only a few objects are animated and the viepoint doesn't change, you can save the color and depth buffer of the scene without the animated object(s) with the WGL_ARB_buffer_region extension ( http://oss.sgi.com/projects/ogl-sample/registry/ ) and restore them before each new animation step like this:
- Draw static scene once.
- Save color and depth buffer of the whole window into buffer region.
- Draw non-static object(s).
- SwapBuffers
- Restore back color and depth buffer from buffer region.
- goto Animation_loop
- each time the static scene changes, goto Start.

Tip: Ff you select a pixelformat with PFD_SWAP_COPY flag set it should be possible to restore only those parts of the back buffer you overdraw with the animated object instead of the whole window.

01-22-2003, 09:17 PM

Thanx for ya reply.

Btw, I am using GLUT not the Win32 programming, is it possible for me to use WGL function in it? Please advise me.


01-23-2003, 07:17 AM
Whatever the mechanism you use to get extension functions normally, wglGetProcAddress or glX_something_I_dunno, use it and' you'll see if you get the pointer.
You might need to include some header but GLUT should already include OS specific API calls.
Just #ifdef your code where things are different if you need crossplatform compatibility and you're set.

01-24-2003, 01:27 PM
Hello dude,
Is there any other technique there to accompolish the task which I mentioned earlier.

Looking for more advise. Please help me out dude!!!

Riaz. http://www.opengl.org/discussion_boards/ubb/frown.gif

01-27-2003, 04:42 AM
Keep a list of all your spheres. Each frame display all the spheres in your list. To draw more spheres, add them to the list. To stop drawing them, remove them from the list.