mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
WGL implementations not supporting wglChoosePixelFormatARB (for antialiasing) no longer crash
When an OpenGL 3.x context cannot be created, the minor version is decreased until it reaches 0 (instead of giving up and switching to a 2.x context immediately) git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1300 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
4418469d97
commit
08f819e49e
@ -247,7 +247,7 @@ void ContextGLX::CreateContext(ContextGLX* shared, unsigned int bitsPerPixel, co
|
||||
GLXContext toShare = shared ? shared->myContext : NULL;
|
||||
|
||||
// Create the OpenGL context -- first try an OpenGL 3.0 context if it is requested
|
||||
if (settings.MajorVersion >= 3)
|
||||
while (mySettings.MajorVersion >= 3)
|
||||
{
|
||||
const GLubyte* name = reinterpret_cast<const GLubyte*>("glXCreateContextAttribsARB");
|
||||
PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = reinterpret_cast<PFNGLXCREATECONTEXTATTRIBSARBPROC>(glXGetProcAddress(name));
|
||||
@ -260,8 +260,8 @@ void ContextGLX::CreateContext(ContextGLX* shared, unsigned int bitsPerPixel, co
|
||||
// Create the context
|
||||
int attributes[] =
|
||||
{
|
||||
GLX_CONTEXT_MAJOR_VERSION_ARB, settings.MajorVersion,
|
||||
GLX_CONTEXT_MINOR_VERSION_ARB, settings.MinorVersion,
|
||||
GLX_CONTEXT_MAJOR_VERSION_ARB, mySettings.MajorVersion,
|
||||
GLX_CONTEXT_MINOR_VERSION_ARB, mySettings.MinorVersion,
|
||||
0, 0
|
||||
};
|
||||
myContext = glXCreateContextAttribsARB(myDisplay, configs[0], toShare, true, attributes);
|
||||
@ -271,8 +271,16 @@ void ContextGLX::CreateContext(ContextGLX* shared, unsigned int bitsPerPixel, co
|
||||
// If we couldn't create an OpenGL 3 context, adjust the settings
|
||||
if (!myContext)
|
||||
{
|
||||
if (mySettings.MinorVersion > 0)
|
||||
{
|
||||
// If the minor version is not 0, we decrease it and try again
|
||||
mySettings.MinorVersion--;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the minor version is 0, we decrease the major version and stop with 3.x contexts
|
||||
mySettings.MajorVersion = 2;
|
||||
mySettings.MinorVersion = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,7 +155,8 @@ void ContextWGL::CreateContext(ContextWGL* shared, unsigned int bitsPerPixel, co
|
||||
{
|
||||
// Get the wglChoosePixelFormatARB function (it is an extension)
|
||||
PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB = reinterpret_cast<PFNWGLCHOOSEPIXELFORMATARBPROC>(wglGetProcAddress("wglChoosePixelFormatARB"));
|
||||
|
||||
if (wglChoosePixelFormatARB)
|
||||
{
|
||||
// Define the basic attributes we want for our window
|
||||
int intAttributes[] =
|
||||
{
|
||||
@ -218,6 +219,13 @@ void ContextWGL::CreateContext(ContextWGL* shared, unsigned int bitsPerPixel, co
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// wglChoosePixelFormatARB not supported ; disabling antialiasing
|
||||
std::cerr << "Antialiasing is not supported ; it will be disabled" << std::endl;
|
||||
mySettings.AntialiasingLevel = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Find a pixel format with no antialiasing, if not needed or not supported
|
||||
if (bestFormat == 0)
|
||||
@ -262,15 +270,15 @@ void ContextWGL::CreateContext(ContextWGL* shared, unsigned int bitsPerPixel, co
|
||||
HGLRC sharedContext = shared ? shared->myContext : NULL;
|
||||
|
||||
// Create the OpenGL context -- first try an OpenGL 3.0 context if it is requested
|
||||
if (settings.MajorVersion >= 3)
|
||||
while (mySettings.MajorVersion >= 3)
|
||||
{
|
||||
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = reinterpret_cast<PFNWGLCREATECONTEXTATTRIBSARBPROC>(wglGetProcAddress("wglCreateContextAttribsARB"));
|
||||
if (wglCreateContextAttribsARB)
|
||||
{
|
||||
int attributes[] =
|
||||
{
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, settings.MajorVersion,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, settings.MinorVersion,
|
||||
WGL_CONTEXT_MAJOR_VERSION_ARB, mySettings.MajorVersion,
|
||||
WGL_CONTEXT_MINOR_VERSION_ARB, mySettings.MinorVersion,
|
||||
0, 0
|
||||
};
|
||||
myContext = wglCreateContextAttribsARB(myDeviceContext, sharedContext, attributes);
|
||||
@ -279,8 +287,16 @@ void ContextWGL::CreateContext(ContextWGL* shared, unsigned int bitsPerPixel, co
|
||||
// If we couldn't create an OpenGL 3 context, adjust the settings
|
||||
if (!myContext)
|
||||
{
|
||||
if (mySettings.MinorVersion > 0)
|
||||
{
|
||||
// If the minor version is not 0, we decrease it and try again
|
||||
mySettings.MinorVersion--;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the minor version is 0, we decrease the major version and stop with 3.x contexts
|
||||
mySettings.MajorVersion = 2;
|
||||
mySettings.MinorVersion = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user