Made the context creation code more flexible, to allow 4.x contexts

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1788 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2011-02-04 22:22:54 +00:00
parent 7c61189f27
commit c48792e933
2 changed files with 14 additions and 10 deletions

View File

@ -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<const GLubyte*>("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);

View File

@ -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<PFNWGLCREATECONTEXTATTRIBSARBPROC>(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);