[Cogl] [PATCH] sdl: Don't set SDL_GL_DOUBLEBUFFER when the swap chain has no pref
Neil Roberts
neil at linux.intel.com
Tue Nov 13 04:10:13 PST 2012
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
More information about the Cogl
mailing list