[cogl] sdl: Don't set SDL_GL_DOUBLEBUFFER when the swap chain has no pref
- From: Neil Roberts <nroberts src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl] sdl: Don't set SDL_GL_DOUBLEBUFFER when the swap chain has no pref
- Date: Fri, 23 Nov 2012 15:19:50 +0000 (UTC)
commit 71e57f99002d5dee79bbd44b3bc57712b99acb55
Author: Neil Roberts <neil linux intel com>
Date: Tue Nov 13 12:10:13 2012 +0000
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>
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 e1dd528..8c4e2ac 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 3ae0962..1c0fc31 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]