diff --git a/src/SFML/Window/Linux/ContextGLX.cpp b/src/SFML/Window/Linux/ContextGLX.cpp index 4e5f1eee..08156bd1 100644 --- a/src/SFML/Window/Linux/ContextGLX.cpp +++ b/src/SFML/Window/Linux/ContextGLX.cpp @@ -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(owner)->GetDisplay(); +{ + // Use the same context as the owner window (important!) + myDisplay = static_cast(owner)->GetDisplay(); // Get the owner window and its device context myWindow = static_cast(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("glXCreateContextAttribsARB"); + const GLubyte* name = reinterpret_cast("glXCreateContextAttribsARB"); PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = reinterpret_cast(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