diff --git a/src/SFML/Window/Linux/GlxContext.cpp b/src/SFML/Window/Linux/GlxContext.cpp index 3cf744e17..020f018f4 100644 --- a/src/SFML/Window/Linux/GlxContext.cpp +++ b/src/SFML/Window/Linux/GlxContext.cpp @@ -223,7 +223,7 @@ void GlxContext::CreateContext(GlxContext* shared, unsigned int bitsPerPixel, co // Get the context to share display lists with GLXContext toShare = shared ? shared->myContext : NULL; - // Create the OpenGL context -- first try an OpenGL 3.0 context if it is requested + // Create the OpenGL context -- first try context versions >= 3.0 if it is requested (they require special code) while (!myContext && (mySettings.MajorVersion >= 3)) { const GLubyte* name = reinterpret_cast("glXCreateContextAttribsARB"); @@ -249,7 +249,8 @@ void GlxContext::CreateContext(GlxContext* shared, unsigned int bitsPerPixel, co XFree(configs); } - // If we couldn't create an OpenGL 3 context, adjust the settings + // If we couldn't create the context, lower the version number and try again -- stop at 3.0 + // Invalid version numbers will be generated by this algorithm (like 3.9), but we really don't care if (!myContext) { if (mySettings.MinorVersion > 0) @@ -259,13 +260,14 @@ void GlxContext::CreateContext(GlxContext* shared, unsigned int bitsPerPixel, co } else { - // If the minor version is 0, we decrease the major version and stop with 3.x contexts - mySettings.MajorVersion = 2; + // If the minor version is 0, we decrease the major version + mySettings.MajorVersion--; + mySettings.MinorVersion = 9; } } } - // If the OpenGL 3.0 context failed or if we don't want one, create a regular OpenGL 1.x/2.x context + // If the OpenGL >= 3.0 context failed or if we don't want one, create a regular OpenGL 1.x/2.x context if (!myContext) { myContext = glXCreateContext(myDisplay, bestVisual, toShare, true); diff --git a/src/SFML/Window/Win32/WglContext.cpp b/src/SFML/Window/Win32/WglContext.cpp index 8d1eaf563..54f32e4a5 100644 --- a/src/SFML/Window/Win32/WglContext.cpp +++ b/src/SFML/Window/Win32/WglContext.cpp @@ -253,7 +253,7 @@ void WglContext::CreateContext(WglContext* shared, unsigned int bitsPerPixel, co // Get the context to share display lists with HGLRC sharedContext = shared ? shared->myContext : NULL; - // Create the OpenGL context -- first try an OpenGL 3.0 context if it is requested + // Create the OpenGL context -- first try context versions >= 3.0 if it is requested (they require special code) while (!myContext && (mySettings.MajorVersion >= 3)) { PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = reinterpret_cast(wglGetProcAddress("wglCreateContextAttribsARB")); @@ -269,7 +269,8 @@ void WglContext::CreateContext(WglContext* shared, unsigned int bitsPerPixel, co myContext = wglCreateContextAttribsARB(myDeviceContext, sharedContext, attributes); } - // If we couldn't create an OpenGL 3 context, adjust the settings + // If we couldn't create the context, lower the version number and try again -- stop at 3.0 + // Invalid version numbers will be generated by this algorithm (like 3.9), but we really don't care if (!myContext) { if (mySettings.MinorVersion > 0) @@ -279,13 +280,14 @@ void WglContext::CreateContext(WglContext* shared, unsigned int bitsPerPixel, co } else { - // If the minor version is 0, we decrease the major version and stop with 3.x contexts - mySettings.MajorVersion = 2; + // If the minor version is 0, we decrease the major version + mySettings.MajorVersion--; + mySettings.MinorVersion = 9; } } } - // If the OpenGL 3.0 context failed or if we don't want one, create a regular OpenGL 1.x/2.x context + // If the OpenGL >= 3.0 context failed or if we don't want one, create a regular OpenGL 1.x/2.x context if (!myContext) { myContext = wglCreateContext(myDeviceContext);