[cogl/wip/cogl-1.14: 54/177] sdl2: Fix GL3 context creation



commit 7963fdb767a4cc67feba28797b648f2bd9205d7f
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>
    
    (cherry picked from commit d46acafa3ea7ba2e6c4ac7a45f00a132df1b2872)

 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 433c0e2..0df2607 100644
--- a/cogl/winsys/cogl-winsys-sdl2.c
+++ b/cogl/winsys/cogl-winsys-sdl2.c
@@ -159,7 +159,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 */
@@ -209,27 +215,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]