[Cogl] [PATCH 2/2] sdl2: Fix GL3 context creation
Neil Roberts
neil at linux.intel.com
Wed Oct 3 04:12:05 PDT 2012
The check to verify whether we've got the right GL context was
checking that the GL version was less than 3 whenever the non-GL3
driver is used. However it looks like the driver is free to return a
GL3 context that is compatible with GL2 if GL2 is requested so this
was breaking the GL2 driver.
This also adds the necessary SDL attributes to request a forward
compatible core context like the GLX and EGL winsys's do. I haven't
actually tested this because it looks like SDL will only create a GL
context with GLX and I haven't got a recent enough X server to handle
the glXCreateContextAttribs request.
---
cogl/winsys/cogl-winsys-sdl2.c | 35 ++++++++++++++---------------------
1 file changed, 14 insertions(+), 21 deletions(-)
diff --git a/cogl/winsys/cogl-winsys-sdl2.c b/cogl/winsys/cogl-winsys-sdl2.c
index cd991a4..4c0583b 100644
--- a/cogl/winsys/cogl-winsys-sdl2.c
+++ b/cogl/winsys/cogl-winsys-sdl2.c
@@ -158,7 +158,13 @@ _cogl_winsys_display_setup (CoglDisplay *display,
else if (display->renderer->driver == COGL_DRIVER_GLES2)
SDL_GL_SetAttribute (SDL_GL_CONTEXT_MAJOR_VERSION, 2);
else if (display->renderer->driver == COGL_DRIVER_GL3)
- SDL_GL_SetAttribute (SDL_GL_CONTEXT_MAJOR_VERSION, 3);
+ {
+ SDL_GL_SetAttribute (SDL_GL_CONTEXT_MAJOR_VERSION, 3);
+ SDL_GL_SetAttribute (SDL_GL_CONTEXT_PROFILE_MASK,
+ SDL_GL_CONTEXT_PROFILE_CORE);
+ SDL_GL_SetAttribute (SDL_GL_CONTEXT_FLAGS,
+ SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG);
+ }
/* Create a dummy 1x1 window that never gets display so that we can
* create a GL context */
@@ -208,27 +214,14 @@ _cogl_winsys_display_setup (CoglDisplay *display,
goto error;
}
- if (gl_version[0] >= '3')
- {
- if (display->renderer->driver == COGL_DRIVER_GL)
- {
- _cogl_set_error (error, COGL_WINSYS_ERROR,
- COGL_WINSYS_ERROR_INIT,
- "The GL driver was requested but SDL is using "
- "GL %c", gl_version[0]);
- goto error;
- }
- }
- else
+ if (display->renderer->driver == COGL_DRIVER_GL3 &&
+ gl_version[0] < '3')
{
- if (display->renderer->driver == COGL_DRIVER_GL3)
- {
- _cogl_set_error (error, COGL_WINSYS_ERROR,
- COGL_WINSYS_ERROR_INIT,
- "The GL3 driver was requested but SDL is using "
- "GL %c", gl_version[0]);
- goto error;
- }
+ _cogl_set_error (error, COGL_WINSYS_ERROR,
+ COGL_WINSYS_ERROR_INIT,
+ "The GL3 driver was requested but SDL is using "
+ "GL %c", gl_version[0]);
+ goto error;
}
break;
--
1.7.11.3.g3c3efa5
More information about the Cogl
mailing list