Results 1 to 6 of 6

Thread: Double buffer

  1. #1

    Double buffer

    How do you do double buffer on WebGL?

    Thanks in advance for your help.
    Best,
    -- Pion

  2. #2
    Member Coolcat's Avatar
    Join Date
    Oct 2009
    Location
    NRW, Germany
    Posts
    75

    Re: Double buffer

    Because I don't see any useful application for single buffering I would claim that double buffering is always enabled.

    However, there might be some effects that require read access to the front buffer. I would recommend to use FrameBufferObjects (FBO) for these special effects.

  3. #3

    Re: Double buffer

    What does it mean that "double buffering is always enabled." ? How does it know when to swap?

    My understanding is that OpenGL does not have swap buffer command. I am looking for the equivalent of glutSwapBuffers() function where it explicitly asks to swap the buffer.
    Best,
    -- Pion

  4. #4
    Member Coolcat's Avatar
    Join Date
    Oct 2009
    Location
    NRW, Germany
    Posts
    75

    Re: Double buffer

    As far as I understand it, WebGL does swap automatically when the browser does stop processing your script. Normally your applications does look like this:

    Code :
    window.setInterval("mainloop()", 33);
     
    function mainloop() {
        /* update */
        ...
     
        /* draw scene */
        ...
    }

    The browser does swap buffers, when it does leave the mainloop function.

    However, there are commands finish() and flush(), but for normal applications there is no need to call them.

  5. #5

    Re: Double buffer

    Thanks for the clarification coolcat.

    But your (pseudo-code) example seems to be still a single buffer rendering.

    Below is the code snippet from http://www.opengl-redbook.com/.

    int main(int argc, char** argv)
    {
    glutInit(&argc, argv);
    glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB); // Request double buffer
    ...
    }

    void display(void)
    {
    glClear(GL_COLOR_BUFFER_BIT);
    glPushMatrix();
    glRotatef(spin, 0.0, 0.0, 1.0);
    glColor3f(1.0, 1.0, 1.0);
    glRectf(-25.0, -25.0, 25.0, 25.0);
    glPopMatrix();

    glutSwapBuffers(); // Explicitly request the swap buffer
    }


    X Windows provides glXSwapBuffers() and Windows provides wglSwapLayerBuffers()

    That's a typical OpenGL double buffer rendering.
    Best,
    -- Pion

  6. #6
    Member Coolcat's Avatar
    Join Date
    Oct 2009
    Location
    NRW, Germany
    Posts
    75

    Re: Double buffer

    Once again...the browser does swap buffers, when it does leave the mainloop() function. After that your interval timer does call mainloop() again. Double buffering is used automatically.

Similar Threads

  1. Replies: 2
    Last Post: 08-19-2011, 05:03 AM
  2. How can I simulate double precision?
    By Rui in forum OpenCL
    Replies: 2
    Last Post: 05-28-2010, 07:11 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
  •