View Full Version : Double-Buffering doesnt work..

10-10-2003, 11:54 PM
Hello again!

Sorry for asking so much, but OpenGL looks somehow strange for a newbie like me... :-)

I created a simple glut-app which uses double-buffering to speed up drawing:

void renderScene(void)
static int painted = 0;
int i=0;

if(painted == 0)
printf("Habe gezeichnet!\n");
glVertex2f(0.1, 0.3);
glVertex2f(0.4, 0.7);

But it seems, that the window remains black. If I remove the if-check it works like expected...
Does anybody know why?

lg Clemens

PS: How fast is glutSwapBuffer() on HW accerlated systems. Is it done in Graphics-HW at all? How many such swaps are possible in one second? (Just about: 100, 1000, 100000, ...)

10-11-2003, 12:17 AM
You have a { too much in your code. Post the correct code so we know what blocks belongs where.

However, if the code is supposed to work the way I think you want it to work (render once, and keep swapping), it won't work. First frame, you render a line, and swap the buffers. The line is now in the front buffer and will now show up on the screen, and the back buffer is undefined. Next frame, you swap again, making the undefined back buffer visible, and making the new back buffer undefined. At this point, you have two buffers with undefined content.

The speed of a buffer swap itself is irrelevant. What affects the speed is in any practical case the time taken to draw the scene.

10-11-2003, 12:22 AM
Thanks for answering!

Hmm, I think you are right.

What I want to do is to draw once and to paint it multiple times to screen, like an image.
I´m searching for a fast hw way to do this.
Any idea this can be done?

lg Clemens

[This message has been edited by Linuxhippy (edited 10-11-2003).]

10-11-2003, 01:13 AM
Copy the image to a texture, and draw it on a quad over the screen. A relevant function would be glCopyTexSubImage, and make sure you're copying from the correct buffer (front vs. back buffer).

10-11-2003, 02:11 AM
Thanks a lot!