[cogl] sdl2: Fix GL3 context creation
- From: Neil Roberts <nroberts src gnome org>
 
- To: commits-list gnome org
 
- Cc: 
 
- Subject: [cogl] sdl2: Fix GL3 context creation
 
- Date: Wed,  3 Oct 2012 13:12:33 +0000 (UTC)
 
commit d46acafa3ea7ba2e6c4ac7a45f00a132df1b2872
Author: Neil Roberts <neil linux intel com>
Date:   Wed Oct 3 12:06:02 2012 +0100
    sdl2: Fix GL3 context creation
    
    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.
    
    Reviewed-by: Robert Bragg <robert linux intel com>
 cogl/winsys/cogl-winsys-sdl2.c |   35 ++++++++++++++---------------------
 1 files 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;
 
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]