[Cogl] [PATCH] sdl: Don't set SDL_GL_DOUBLEBUFFER when the swap chain has no pref
Robert Bragg
robert at sixbynine.org
Fri Nov 23 06:11:52 PST 2012
This looks good to me:
Reviewed-by: Robert Bragg <robert at linux.intel.com>
thanks,
- Robert
On Tue, Nov 13, 2012 at 12:10 PM, Neil Roberts <neil at linux.intel.com> wrote:
> The ‘length’ for the swap chain is initially -1 which is supposed to
> mean ‘no preference’. However, both of the SDL winsys's were
> explicitly setting the SDL_GL_DOUBLEBUFFER attribute to zero in that
> case which would try to disable double buffering.
>
> On OS X, the equivalent to eglSwapBuffers (ie, [NSOpenGLContext
> flushBuffer]) does nothing for a single buffer context. The
> cogl-sdl-hello example does not specify the swap chain length so
> presumably it would end up with a single buffer config. When
> cogl_onscreen_swap_buffers is called it therefore does nothing and
> nothing is painted.
>
> I guess to make single-buffered contexts actually useful we should
> expose some public equivalent to glFlush so that you can ensure the
> rendering commands will actually hit the buffer. Alteneratively we
> could document that cogl_onscreen_swap_buffers performs this task on
> single-buffered configs and then we could make the SDL winsys
> explicitly call glFlush in that case.
> ---
> cogl/winsys/cogl-winsys-sdl.c | 5 +++--
> cogl/winsys/cogl-winsys-sdl2.c | 5 +++--
> 2 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/cogl/winsys/cogl-winsys-sdl.c b/cogl/winsys/cogl-winsys-sdl.c
> index ccb0764..63abbd0 100644
> --- a/cogl/winsys/cogl-winsys-sdl.c
> +++ b/cogl/winsys/cogl-winsys-sdl.c
> @@ -135,8 +135,9 @@ set_gl_attribs_from_framebuffer_config
> (CoglFramebufferConfig *config)
> SDL_GL_SetAttribute (SDL_GL_STENCIL_SIZE,
> config->need_stencil ? 1 : 0);
>
> - SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER,
> - config->swap_chain->length > 1 ? 1 : 0);
> + if (config->swap_chain->length >= 0)
> + SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER,
> + config->swap_chain->length > 1 ? 1 : 0);
>
> SDL_GL_SetAttribute (SDL_GL_ALPHA_SIZE,
> config->swap_chain->has_alpha ? 1 : 0);
> diff --git a/cogl/winsys/cogl-winsys-sdl2.c
> b/cogl/winsys/cogl-winsys-sdl2.c
> index 4c0583b..0df2607 100644
> --- a/cogl/winsys/cogl-winsys-sdl2.c
> +++ b/cogl/winsys/cogl-winsys-sdl2.c
> @@ -131,8 +131,9 @@ set_gl_attribs_from_framebuffer_config
> (CoglFramebufferConfig *config)
> SDL_GL_SetAttribute (SDL_GL_STENCIL_SIZE,
> config->need_stencil ? 1 : 0);
>
> - SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER,
> - config->swap_chain->length > 1 ? 1 : 0);
> + if (config->swap_chain->length >= 0)
> + SDL_GL_SetAttribute (SDL_GL_DOUBLEBUFFER,
> + config->swap_chain->length > 1 ? 1 : 0);
>
> SDL_GL_SetAttribute (SDL_GL_ALPHA_SIZE,
> config->swap_chain->has_alpha ? 1 : 0);
> --
> 1.7.11.3.g3c3efa5
>
> _______________________________________________
> Cogl mailing list
> Cogl at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/cogl
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/cogl/attachments/20121123/a7e8c23e/attachment.html>
More information about the Cogl
mailing list