Activated OpenGL 3 contexts on Linux

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1210 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2009-08-28 20:17:10 +00:00
parent 9944cdcbba
commit a6e353f11b

View File

@ -43,9 +43,9 @@ ContextGLX::ContextGLX(ContextGLX* shared) :
myWindow (0),
myContext (NULL),
myOwnsWindow(true)
{
// Open a connection with the X server
myDisplay = XOpenDisplay(NULL);
{
// Open a connection with the X server
myDisplay = XOpenDisplay(NULL);
// Create a dummy window (disabled and hidden)
int screen = DefaultScreen(myDisplay);
@ -75,9 +75,9 @@ ContextGLX::ContextGLX(ContextGLX* shared, const WindowImpl* owner, unsigned int
myWindow (0),
myContext (NULL),
myOwnsWindow(false)
{
// Use the same context as the owner window (important!)
myDisplay = static_cast<const WindowImplX11*>(owner)->GetDisplay();
{
// Use the same context as the owner window (important!)
myDisplay = static_cast<const WindowImplX11*>(owner)->GetDisplay();
// Get the owner window and its device context
myWindow = static_cast<Window>(owner->GetHandle());
@ -110,12 +110,12 @@ ContextGLX::~ContextGLX()
{
XDestroyWindow(myDisplay, myWindow);
XFlush(myDisplay);
}
// Close the connection with the X server
if (myOwnsWindow)
{
XCloseDisplay(myDisplay);
}
// Close the connection with the X server
if (myOwnsWindow)
{
XCloseDisplay(myDisplay);
}
}
@ -275,18 +275,18 @@ void ContextGLX::CreateContext(ContextGLX* shared, unsigned int bitsPerPixel, co
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");
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)
{
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;
}
return;
}
// Create the context
int attributes[] =
{
@ -295,17 +295,17 @@ void ContextGLX::CreateContext(ContextGLX* shared, unsigned int bitsPerPixel, co
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