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,13 +274,39 @@ 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 -- first try an OpenGL 3.0 context if it is supported
|
||||||
|
/*const GLubyte* name = reinterpret_cast<const GLubyte*>("glXCreateContextAttribsARB");
|
||||||
|
PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = reinterpret_cast<PFNGLXCREATECONTEXTATTRIBSARBPROC>(glXGetProcAddress(name));
|
||||||
|
if (glXCreateContextAttribsARB)
|
||||||
|
{
|
||||||
|
int nbConfigs = 0;
|
||||||
|
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
|
// 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);
|
myContext = glXCreateContext(myDisplay, bestVisual, toShare, true);
|
||||||
if (!myContext)
|
if (!myContext)
|
||||||
{
|
{
|
||||||
std::cerr << "Failed to create an OpenGL context for this window" << std::endl;
|
std::cerr << "Failed to create an OpenGL context for this window" << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Update the creation settings from the chosen format
|
// Update the creation settings from the chosen format
|
||||||
int depth, stencil;
|
int depth, stencil;
|
||||||
|
Loading…
Reference in New Issue
Block a user