Results 1 to 5 of 5

Thread: Double-Buffering doesnt work..

  1. #1
    Member Newbie
    Join Date
    Oct 2003
    Posts
    36

    Double-Buffering doesnt work..

    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");
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_LINES);
    glVertex2f(0.1, 0.3);
    glVertex2f(0.4, 0.7);
    glEnd();
    }
    painted++;
    }
    glFlush();
    glutSwapBuffers();
    }

    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, ...)

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Double-Buffering doesnt work..

    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.

  3. #3
    Member Newbie
    Join Date
    Oct 2003
    Posts
    36

    Re: Double-Buffering doesnt work..

    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).]

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Double-Buffering doesnt work..

    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).

  5. #5
    Member Newbie
    Join Date
    Oct 2003
    Posts
    36

    Re: Double-Buffering doesnt work..

    Thanks a lot!

Similar Threads

  1. Double buffering
    By link19 in forum OpenGL: Basic Coding
    Replies: 18
    Last Post: 10-28-2003, 09:48 AM
  2. double buffering
    By cobbal in forum OpenGL: macOS
    Replies: 1
    Last Post: 03-17-2003, 05:27 PM
  3. Double buffering
    By Corillian in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 02-19-2001, 07:31 PM
  4. double buffering
    By niranjan in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 01-09-2001, 07:08 PM
  5. Help with Double Buffering
    By Zackiepoo in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 03-19-2000, 10:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean