diff -r 50bf98210aae include/SDL_video.h --- a/include/SDL_video.h Thu Aug 18 22:43:37 2011 +0200 +++ b/include/SDL_video.h Mon Aug 22 19:51:38 2011 +0200 @@ -182,9 +182,24 @@ SDL_GL_ACCELERATED_VISUAL, SDL_GL_RETAINED_BACKING, SDL_GL_CONTEXT_MAJOR_VERSION, - SDL_GL_CONTEXT_MINOR_VERSION + SDL_GL_CONTEXT_MINOR_VERSION, + SDL_GL_CONTEXT_FLAGS, + SDL_GL_CONTEXT_PROFILE_MASK } SDL_GLattr; +typedef enum +{ + SDL_GL_CONTEXT_PROFILE_CORE = 0x0001, + SDL_GL_CONTEXT_PROFILE_COMPATIBILITY = 0x0002 +} SDL_GLprofile; + +typedef enum +{ + SDL_GL_CONTEXT_DEBUG_FLAG = 0x0001, + SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG = 0x0002, + SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG = 0x0004 +} SDL_GLcontextFlag; + /* Function prototypes */ diff -r 50bf98210aae src/video/SDL_sysvideo.h --- a/src/video/SDL_sysvideo.h Thu Aug 18 22:43:37 2011 +0200 +++ b/src/video/SDL_sysvideo.h Mon Aug 22 19:51:38 2011 +0200 @@ -270,6 +270,8 @@ int accelerated; int major_version; int minor_version; + int flags; + int profile_mask; int retained_backing; int driver_loaded; char driver_path[256]; diff -r 50bf98210aae src/video/SDL_video.c --- a/src/video/SDL_video.c Thu Aug 18 22:43:37 2011 +0200 +++ b/src/video/SDL_video.c Mon Aug 22 19:51:38 2011 +0200 @@ -491,6 +491,8 @@ _this->gl_config.major_version = 2; _this->gl_config.minor_version = 0; #endif + _this->gl_config.flags = 0; + _this->gl_config.profile_mask = 0; /* Initialize the video subsystem */ if (_this->VideoInit(_this) < 0) { @@ -2276,6 +2278,12 @@ case SDL_GL_CONTEXT_MINOR_VERSION: _this->gl_config.minor_version = value; break; + case SDL_GL_CONTEXT_FLAGS: + _this->gl_config.flags = value; + break; + case SDL_GL_CONTEXT_PROFILE_MASK: + _this->gl_config.profile_mask = value; + break; default: SDL_SetError("Unknown OpenGL attribute"); retval = -1; @@ -2422,6 +2430,16 @@ *value = _this->gl_config.minor_version; return 0; } + case SDL_GL_CONTEXT_FLAGS: + { + *value = _this->gl_config.flags; + return 0; + } + case SDL_GL_CONTEXT_PROFILE_MASK: + { + *value = _this->gl_config.profile_mask; + return 0; + } default: SDL_SetError("Unknown OpenGL attribute"); return -1; diff -r 50bf98210aae src/video/windows/SDL_windowsopengl.c --- a/src/video/windows/SDL_windowsopengl.c Thu Aug 18 22:43:37 2011 +0200 +++ b/src/video/windows/SDL_windowsopengl.c Mon Aug 22 19:51:38 2011 +0200 @@ -37,6 +37,21 @@ #define WGL_CONTEXT_FLAGS_ARB 0x2093 #define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 #define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 + +#ifndef WGL_ARB_create_context_profile +#define WGL_ARB_create_context_profile +#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 +#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 +#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 +#endif + +#ifndef WGL_ARB_create_context_robustness +#define WGL_ARB_create_context_robustness +#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 +#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#endif #endif typedef HGLRC(APIENTRYP PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, @@ -517,11 +532,28 @@ SDL_SetError("GL 3.x is not supported"); context = temp_context; } else { - int attribs[] = { + /* max 8 attributes plus terminator */ + int attribs[9] = { WGL_CONTEXT_MAJOR_VERSION_ARB, _this->gl_config.major_version, WGL_CONTEXT_MINOR_VERSION_ARB, _this->gl_config.minor_version, 0 }; + int iattr = 4; + + /* SDL profile bits match WGL profile bits */ + if( _this->gl_config.profile_mask != 0 ) { + attribs[iattr++] = WGL_CONTEXT_PROFILE_MASK_ARB; + attribs[iattr++] = _this->gl_config.profile_mask; + } + + /* SDL flags match WGL flags */ + if( _this->gl_config.flags != 0 ) { + attribs[iattr++] = WGL_CONTEXT_FLAGS_ARB; + attribs[iattr++] = _this->gl_config.flags; + } + + attribs[iattr++] = 0; + /* Create the GL 3.x context */ context = wglCreateContextAttribsARB(hdc, 0, attribs); /* Delete the GL 2.x context */ diff -r 50bf98210aae src/video/x11/SDL_x11opengl.c --- a/src/video/x11/SDL_x11opengl.c Thu Aug 18 22:43:37 2011 +0200 +++ b/src/video/x11/SDL_x11opengl.c Mon Aug 22 19:51:38 2011 +0200 @@ -64,11 +64,6 @@ #define GLX_CONTEXT_DEBUG_BIT_ARB 0x0001 #define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 -#ifndef GLX_EXT_swap_control -#define GLX_SWAP_INTERVAL_EXT 0x20F1 -#define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2 -#endif - /* Typedef for the GL 3.0 context creation function */ typedef GLXContext(*PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display * dpy, GLXFBConfig config, @@ -77,6 +72,26 @@ Bool direct, const int *attrib_list); + +#ifndef GLX_ARB_create_context_profile +#define GLX_ARB_create_context_profile +#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 +#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 +#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 +#endif + +#ifndef GLX_ARB_create_context_robustness +#define GLX_ARB_create_context_robustness +#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GLX_NO_RESET_NOTIFICATION_ARB 0x8261 +#define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#endif +#endif + +#ifndef GLX_EXT_swap_control +#define GLX_SWAP_INTERVAL_EXT 0x20F1 +#define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2 #endif #define OPENGL_REQUIRS_DLOPEN @@ -429,13 +444,29 @@ SDL_SetError("Could not create GL context"); return NULL; } else { - int attribs[] = { + /* max 8 attributes plus terminator */ + int attribs[9] = { GLX_CONTEXT_MAJOR_VERSION_ARB, _this->gl_config.major_version, GLX_CONTEXT_MINOR_VERSION_ARB, _this->gl_config.minor_version, 0 }; + int iattr = 4; + + /* SDL profile bits match GLX profile bits */ + if( _this->gl_config.profile_mask != 0 ) { + attribs[iattr++] = GLX_CONTEXT_PROFILE_MASK_ARB; + attribs[iattr++] = _this->gl_config.profile_mask; + } + + /* SDL flags match GLX flags */ + if( _this->gl_config.flags != 0 ) { + attribs[iattr++] = GLX_CONTEXT_FLAGS_ARB; + attribs[iattr++] = _this->gl_config.flags; + } + + attribs[iattr++] = 0; /* Get a pointer to the context creation function for GL 3.0 */ PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs =