mirror of
https://github.com/SFML/SFML.git
synced 2024-11-28 22:31:09 +08:00
Added automatic support for OpenGL 3.0 contexts on Linux
git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1197 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
parent
9229a27932
commit
357e89696b
@ -274,12 +274,38 @@ void ContextGLX::CreateContext(ContextGLX* shared, unsigned int bitsPerPixel, co
|
|||||||
// Get the context to share display lists with
|
// Get the context to share display lists with
|
||||||
GLXContext toShare = shared ? shared->myContext : NULL;
|
GLXContext toShare = shared ? shared->myContext : NULL;
|
||||||
|
|
||||||
// Create the context
|
// Create the context -- first try an OpenGL 3.0 context if it is supported
|
||||||
myContext = glXCreateContext(myDisplay, bestVisual, toShare, true);
|
/*const GLubyte* name = reinterpret_cast<const GLubyte*>("glXCreateContextAttribsARB");
|
||||||
if (!myContext)
|
PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = reinterpret_cast<PFNGLXCREATECONTEXTATTRIBSARBPROC>(glXGetProcAddress(name));
|
||||||
|
if (glXCreateContextAttribsARB)
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to create an OpenGL context for this window" << std::endl;
|
int nbConfigs = 0;
|
||||||
return;
|
GLXFBConfig* configs = glXChooseFBConfig(myDisplay, DefaultScreen(myDisplay), NULL, &nbConfigs);
|
||||||
|
if (!configs || !nbConfigs)
|
||||||
|
{
|
||||||
|
std::cerr << "Failed to retrieve the framebuffer configuration" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the context
|
||||||
|
int attributes[] =
|
||||||
|
{
|
||||||
|
GLX_CONTEXT_MAJOR_VERSION_ARB, 3,
|
||||||
|
GLX_CONTEXT_MINOR_VERSION_ARB, 0,
|
||||||
|
0, 0
|
||||||
|
};
|
||||||
|
myContext = glXCreateContextAttribsARB(myDisplay, configs[0], toShare, true, attributes);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
// If the OpenGL 3.0 context failed, create a regular OpenGL 1.x context
|
||||||
|
if (!myContext)
|
||||||
|
{
|
||||||
|
myContext = glXCreateContext(myDisplay, bestVisual, toShare, true);
|
||||||
|
if (!myContext)
|
||||||
|
{
|
||||||
|
std::cerr << "Failed to create an OpenGL context for this window" << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the creation settings from the chosen format
|
// Update the creation settings from the chosen format
|
||||||
|
Loading…
Reference in New Issue
Block a user