SDL2, GL3.2 and Lion?

Greetings,

Has anyone managed to get OpenGL 3.2 on Lion working with SDL2?

I trolled the list archives and found the tip about updating SDL_cocoaopengl.m, however, no matter what I do I can’t get fragment or vertex shader programs to display anything.

I’ve verified the vendor and gl version strings are 3.2, and I can retrieve the list of extensions using glGetStringi, etc.

I’ve placed a call that prints the result of GLGetErrorString after every GL call and verified I’m not getting any GL errors.

The only thing I can guess is that there’s still not something right about the context initialization; but based on Lion docs, I can’t figure out what that is.

These are the changes I applied to SDL-2:

diff -r 601b0e251822 include/SDL_config_macosx.h
— a/include/SDL_config_macosx.h Mon Apr 09 23:55:43 2012 -0400
+++ b/include/SDL_config_macosx.h Sun Apr 29 20:54:23 2012 -0700
@@ -130,7 +130,7 @@
/* Enable various video drivers */
#define SDL_VIDEO_DRIVER_COCOA 1
#define SDL_VIDEO_DRIVER_DUMMY 1
-#define SDL_VIDEO_DRIVER_X11 1
+//#define SDL_VIDEO_DRIVER_X11 1
#define SDL_VIDEO_DRIVER_X11_DYNAMIC “/usr/X11R6/lib/libX11.6.dylib”
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT “/usr/X11R6/lib/libXext.6.dylib”
#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "/usr/X11R6/lib/libXinerama.1.dylib"
diff -r 601b0e251822 src/video/cocoa/SDL_cocoamodes.m
— a/src/video/cocoa/SDL_cocoamodes.m Mon Apr 09 23:55:43 2012 -0400
+++ b/src/video/cocoa/SDL_cocoamodes.m Sun Apr 29 20:54:23 2012 -0700
@@ -102,9 +102,6 @@
case kCGErrorCannotComplete:
error = “kCGErrorCannotComplete”;
break;

  • case kCGErrorNameTooLong:
  •    error = "kCGErrorNameTooLong";
    
  •    break;
    
    case kCGErrorNotImplemented:
    error = “kCGErrorNotImplemented”;
    break;
    @@ -114,9 +111,6 @@
    case kCGErrorTypeCheck:
    error = “kCGErrorTypeCheck”;
    break;
  • case kCGErrorNoCurrentPoint:
  •    error = "kCGErrorNoCurrentPoint";
    
  •    break;
    
    case kCGErrorInvalidOperation:
    error = “kCGErrorInvalidOperation”;
    break;
    diff -r 601b0e251822 src/video/cocoa/SDL_cocoaopengl.m
    — a/src/video/cocoa/SDL_cocoaopengl.m Mon Apr 09 23:55:43 2012 -0400
    +++ b/src/video/cocoa/SDL_cocoaopengl.m Sun Apr 29 20:54:23 2012 -0700
    @@ -133,6 +133,14 @@
    }
    }

+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7

  • if(_this->gl_config.major_version == 3 && _this->gl_config.minor_version == 2)
  • {
  •   attr[i++] = NSOpenGLPFAOpenGLProfile;
    
  •   attr[i++] = NSOpenGLProfileVersion3_2Core;
    
  • }
    +#endif+
    attr[i++] = NSOpenGLPFAScreenMask;
    attr[i++] = CGDisplayIDToOpenGLDisplayMask(displaydata->display);
    attr[i] = 0;

-Shawn

If OpenGL tells you, that you have a version 3.2 context, then you have a version 3.2 context and context creation was successful.

I guess the issue is somewhere in your OpenGL code, there are some things that work differently in core if you’re coming from compatibility contexts, e.g. you must create and bind a VAO in core, while you always have a default VAO bound in compatibility mode.

If OpenGL tells you, that you have a version 3.2 context, then you have a version 3.2 context and context creation was successful.

I guess the issue is somewhere in your OpenGL code, there are some things that work differently in core if you’re coming from compatibility contexts, e.g. you must create and bind a VAO in core, while you always have a default VAO bound in compatibility mode.

So it would seem. I tried my little experiment again switching back from the native cocoa implementation to using SDL, and it seems to work just fine now.

My patch to SDL was necessary though…

Sorry for the noise,
-ShawnOn May 2, 2012, at 7:17 AM, mbentrup wrote: