Skip to content

Commit

Permalink
Fixed GLX extensions being loaded too late preventing multisampling c…
Browse files Browse the repository at this point in the history
…onfiguration information from being read during format selection. GLX extensions are now loaded as early as possible either in a constructor of GlxContext or GlxContext::selectBestVisual.
  • Loading branch information
binary1248 committed Jan 18, 2017
1 parent 70e3c35 commit 6fabc38
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions src/SFML/Window/Unix/GlxContext.cpp
Expand Up @@ -105,10 +105,11 @@ m_ownsWindow(false)
// Save the creation settings
m_settings = ContextSettings();

// Make sure that extensions are initialized if this is not the shared context
// The shared context is the context used to initialize the extensions
if (shared && shared->m_display)
ensureExtensionsInit(shared->m_display, DefaultScreen(shared->m_display));
// Open the connection with the X server
m_display = OpenDisplay();

// Make sure that extensions are initialized
ensureExtensionsInit(m_display, DefaultScreen(m_display));

// Create the rendering surface (window or pbuffer if supported)
createSurface(shared, 1, 1, VideoMode::getDesktopMode().bitsPerPixel);
Expand All @@ -129,10 +130,11 @@ m_ownsWindow(false)
// Save the creation settings
m_settings = settings;

// Make sure that extensions are initialized if this is not the shared context
// The shared context is the context used to initialize the extensions
if (shared && shared->m_display)
ensureExtensionsInit(shared->m_display, DefaultScreen(shared->m_display));
// Open the connection with the X server
m_display = OpenDisplay();

// Make sure that extensions are initialized
ensureExtensionsInit(m_display, DefaultScreen(m_display));

// Create the rendering surface from the owner window
createSurface(static_cast< ::Window>(owner->getSystemHandle()));
Expand All @@ -153,10 +155,11 @@ m_ownsWindow(false)
// Save the creation settings
m_settings = settings;

// Make sure that extensions are initialized if this is not the shared context
// The shared context is the context used to initialize the extensions
if (shared && shared->m_display)
ensureExtensionsInit(shared->m_display, DefaultScreen(shared->m_display));
// Open the connection with the X server
m_display = OpenDisplay();

// Make sure that extensions are initialized
ensureExtensionsInit(m_display, DefaultScreen(m_display));

// Create the rendering surface (window or pbuffer if supported)
createSurface(shared, width, height, VideoMode::getDesktopMode().bitsPerPixel);
Expand Down Expand Up @@ -269,9 +272,6 @@ void GlxContext::display()
////////////////////////////////////////////////////////////
void GlxContext::setVerticalSyncEnabled(bool enabled)
{
// Make sure that extensions are initialized
ensureExtensionsInit(m_display, DefaultScreen(m_display));

int result = 0;

// Prioritize the EXT variant and fall back to MESA or SGI if needed
Expand Down Expand Up @@ -310,6 +310,9 @@ void GlxContext::setVerticalSyncEnabled(bool enabled)
////////////////////////////////////////////////////////////
XVisualInfo GlxContext::selectBestVisual(::Display* display, unsigned int bitsPerPixel, const ContextSettings& settings)
{
// Make sure that extensions are initialized
ensureExtensionsInit(display, DefaultScreen(display));

// Retrieve all the visuals
int count;
XVisualInfo* visuals = XGetVisualInfo(display, 0, NULL, &count);
Expand Down Expand Up @@ -450,8 +453,6 @@ void GlxContext::updateSettingsFromWindow()
////////////////////////////////////////////////////////////
void GlxContext::createSurface(GlxContext* shared, unsigned int width, unsigned int height, unsigned int bitsPerPixel)
{
m_display = OpenDisplay();

// Choose the visual according to the context settings
XVisualInfo visualInfo = selectBestVisual(m_display, bitsPerPixel, m_settings);

Expand Down Expand Up @@ -545,8 +546,6 @@ void GlxContext::createSurface(GlxContext* shared, unsigned int width, unsigned
////////////////////////////////////////////////////////////
void GlxContext::createSurface(::Window window)
{
m_display = OpenDisplay();

// A window already exists, so just use it
m_window = window;

Expand Down

0 comments on commit 6fabc38

Please sign in to comment.