Wrapping the glDrawbuffer and glReadbuffer

Help
Salvatore
2005-12-12
2013-04-17
  • Salvatore
    Salvatore
    2005-12-12

    Hallo,

    To port Blender on a PocketPC (more information here http://blenderce.blogspirit.com/\), I am writing a wrapper on top of OpenGL ES.
    I am now working on wrapping the glDrawbuffer(front/back) and glReadbuffer(front/back) functionalities. To do it, I am using two windowSurfaces, the “normal” one for the back buffer and an other windowSurface for the frontBuffer.
    Is it really possible to create two windowSurfaces associated with the same display and the same eglcontext and use eglMakeCurrent to work with the proper one? Or is it better to use Pbuffer or Pixmap surfaces… I didn’t understand how to post their content to the screen… Because as soon as everything is done on the front buffer, it should appear to the screen but Pbuffers or Pimap doesn’t support eglswapbuffer. The specification says that these surfaces are for “offscreen” work…

    Thanks for your help,
    Salvatore

     
    • There is no such thing as a front/back buffer in EGL. All rendering surfaces are off-screen during rendering, but suitable ones (particularly window surfaces) can be posted to the screen using eglSwapBuffers.

      - Martin

       
    • Salvatore
      Salvatore
      2005-12-13

      Hallo Martin,

      Thanks for your answer.
      If I understand good, we make our rendering in off screen surfaces: Window surface, pbuffer surface or pixmap surface.

      To post the content of a window surface, we need to make it current with eglmakecurrent and then swap it with eglswapbuffer.

      But for pbuffer surface and pixmap surface, how can I swap their content? How can I transfer pixels from a pbuffer or pixmap surface to the screen? eglswapbuffer works only for windows surfaces. And for pbuffer?

      If only window surfaces can be transferred to the screen, can I create 2 window surfaces associated to the SAME window? Something like that:

      gles_current_display = eglGetCurrentDisplay();
      gles_current_context = eglGetCurrentContext();
      egl_back_surface = eglGetCurrentSurface(EGL_DRAW);

      //code defining configs

      current_window = GetActiveWindow();
      egl_front_surface = eglCreateWindowSurface(gles_current_display,configs, current_window, NULL); //create a front buffer surcace id

      No error are returned but it doesn’t seems to work.

      Thanks for your help,

      Salvatore

       
      • OK, again, there is no such thing as a back surface.

        gles_current_display = eglGetCurrentDisplay();
        gles_current_context = eglGetCurrentContext();
        //code defining configs

        current_window = GetActiveWindow();
        egl_front_surface = eglCreateWindowSurface(gles_current_display,configs, current_window, NULL); //create a front buffer surcace id
        egl_back_surface = eglCreateWindowSurface(gles_current_display,configs, current_window, NULL); //create a back buffer surcace id

        In eglMakeCurrent you specify which surface you are rendering on.

        So the order is:

        eglMakeCurrent(...); // select the surface to render on
        // drawing code
        eglSwapBuffers(...); // post content to the screen

        Whatever surface you pass into the calls is the one being drawn on/the one being copied to the display.

        Does this help?

        - HM

         
    • Salvatore
      Salvatore
      2005-12-14

      Hallo Martin,

      Thanks a lot for these clarifications. Now it is clear and simple. Of course it helps :=)

      Thanks again,
      Salvatore