Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Double buffering

  1. #1
    Intern Contributor
    Join Date
    Jan 2001
    Location
    Canada
    Posts
    78

    Double buffering

    When i rotate an object, i get heavy flickering. I understand that double buffering will prevent this, however i do not know how to implement it.
    I did a search in this forum and found that its quite simple using GLUT, but i am not. There was no help for implementing it for Win32/MFC. Im using VC++6.0 and would appreciate suggestions.
    TIA

  2. #2
    Intern Contributor
    Join Date
    Jan 2001
    Location
    Canada
    Posts
    78

    Re: Double buffering

    I realized i have to set the PFD_DOUBLEBUFFER flag in my SetWindowPixelFormat() method. Then i call SwapBuffers(dc.GetSafeHdc()); in my OnPaint()...but this has no effect on my view. Still have flickering when animating my object.
    Ideas please??!

  3. #3
    Intern Contributor
    Join Date
    Jan 2001
    Location
    California
    Posts
    80

    Re: Double buffering

    you on the right track.
    you do need to specify PFD_DOUBLEBUFFER when filling in your PIXELFORMATDESCRIPTOR structure. then, to flip the buffers you call SwapBuffers(HDC).

    if you need more info, your best bet is to read NeHe's tutorial on setting up a window in Windows. go to http://nehe.gamedev.net for this tutorial

    - Dave

    [This message has been edited by Warrior (edited 04-16-2001).]

  4. #4
    Junior Member Newbie
    Join Date
    Apr 2001
    Location
    Honolulu, HI, US
    Posts
    11

    Re: Double buffering

    I've just started learning how to program in OpenGL through a book called "OpenGL SuperBible". I came across the topics of double buffering and single buffering. To enable double buffering you should initialize it within the display mode before creating the window.

    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);

    Also, you should use

    glutSwapBuffers();

    at the end of the Rendering function instead of

    glFlush();

  5. #5
    Intern Contributor
    Join Date
    Jan 2001
    Location
    Canada
    Posts
    78

    Re: Double buffering

    Thx Danny...but if you had read my first post, im not using GLUT.
    BTW, im still getting flickering and not sure why double buffering would not be enabled. Ive looked through NeHe's first tut and dont think im missing anything. Could there be something in my code that would prevent it?
    Thx...

  6. #6
    Intern Contributor
    Join Date
    Dec 2000
    Location
    Halifax, Nova Scotia, Canada
    Posts
    90

    Re: Double buffering

    You might actually be using double buffers correctly and still get flickering if you have some combination of:
    software rendering, a lot of polygons, slow computer, vsync disabled.
    Joe

  7. #7
    Junior Member Newbie
    Join Date
    Apr 2001
    Location
    Moscow,Russia
    Posts
    6

    Re: Double buffering

    Maybe
    glFinish();
    SwapBuffers(wglGetCurrentDC()); ?

  8. #8
    Junior Member Newbie
    Join Date
    Dec 1969
    Location
    Munich,Germany
    Posts
    15

    Re: Double buffering

    Are you sure that you are rendering to the backbuffer with using glDrawBuffer(GL_BACK)

    Chris
    yes

  9. #9
    Intern Contributor
    Join Date
    Jan 2001
    Location
    Canada
    Posts
    78

    Re: Double buffering

    My computer is fast, but i am drawing a lot of polygons...so possibly youre right. However, I commented out the SwapBuffer() call and my rendering is still visible. Does this mean that i am not drawing to the back buffer? I made the call glDrawBuffer(GL_BACK)right before i call my rendering function in OnPaint(). Is this the correct place for it?
    Thx for your sugggestions...

  10. #10
    Senior Member OpenGL Pro
    Join Date
    Oct 2000
    Location
    Fargo, ND
    Posts
    1,797

    Re: Double buffering

    It sounds like you are using MFC. Try over-riding the OnEraseBkgnd() function and make it return TRUE.
    Deiussum
    Software Engineer and OpenGL enthusiast

Posting Permissions

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