summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2012-11-13 12:10:13 +0000
committerNeil Roberts <neil@linux.intel.com>2012-11-23 14:43:13 +0000
commit71e57f99002d5dee79bbd44b3bc57712b99acb55 (patch)
tree27b9f19768f75fb5875ec2b3b9bcd2dc854173c9
parent05190519bad4519e66cbdb5326943c832d15a841 (diff)
downloadcogl-71e57f99002d5dee79bbd44b3bc57712b99acb55.tar.gz
sdl: Don't set SDL_GL_DOUBLEBUFFER when the swap chain has no pref
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. Alternatively 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. Reviewed-by: Robert Bragg <robert@linux.intel.com>
-rw-r--r--cogl/winsys/cogl-winsys-sdl.c5
-rw-r--r--cogl/winsys/cogl-winsys-sdl2.c5
2 files changed, 6 insertions, 4 deletions
diff --git a/cogl/winsys/cogl-winsys-sdl.c b/cogl/winsys/cogl-winsys-sdl.c
index e1dd5281..8c4e2ac1 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 3ae09624..1c0fc316 100644
--- a/cogl/winsys/cogl-winsys-sdl2.c
+++ b/cogl/winsys/cogl-winsys-sdl2.c
@@ -137,8 +137,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);