1
0
Fork 0

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>

(cherry picked from commit 71e57f99002d5dee79bbd44b3bc57712b99acb55)
This commit is contained in:
Neil Roberts 2012-11-13 12:10:13 +00:00
parent 0e33654efb
commit 6a62e3077b
2 changed files with 6 additions and 4 deletions

View file

@ -134,8 +134,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);

View file

@ -130,8 +130,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);