Android: Copy the selected EGL context's settings to SFML

This commit is contained in:
Mario Liebisch 2016-01-06 22:23:20 +01:00 committed by Lukas Dürrenberger
parent fe9b9c0cc7
commit 499eb09642
2 changed files with 30 additions and 0 deletions

View File

@ -85,6 +85,7 @@ m_config (NULL)
// Get the best EGL config matching the default video settings // Get the best EGL config matching the default video settings
m_config = getBestConfig(m_display, VideoMode::getDesktopMode().bitsPerPixel, ContextSettings()); m_config = getBestConfig(m_display, VideoMode::getDesktopMode().bitsPerPixel, ContextSettings());
updateSettings();
// Note: The EGL specs say that attrib_list can be NULL when passed to eglCreatePbufferSurface, // Note: The EGL specs say that attrib_list can be NULL when passed to eglCreatePbufferSurface,
// but this is resulting in a segfault. Bug in Android? // but this is resulting in a segfault. Bug in Android?
@ -123,6 +124,7 @@ m_config (NULL)
// Get the best EGL config matching the requested video settings // Get the best EGL config matching the requested video settings
m_config = getBestConfig(m_display, bitsPerPixel, settings); m_config = getBestConfig(m_display, bitsPerPixel, settings);
updateSettings();
// Create EGL context // Create EGL context
createContext(shared); createContext(shared);
@ -250,10 +252,33 @@ EGLConfig EglContext::getBestConfig(EGLDisplay display, unsigned int bitsPerPixe
// Ask EGL for the best config matching our video settings // Ask EGL for the best config matching our video settings
eglCheck(eglChooseConfig(display, attributes, configs, 1, &configCount)); eglCheck(eglChooseConfig(display, attributes, configs, 1, &configCount));
// TODO: This should check EGL_CONFORMANT and pick the first conformant configuration.
return configs[0]; return configs[0];
} }
////////////////////////////////////////////////////////////
void EglContext::updateSettings()
{
EGLint tmp;
// Update the internal context settings with the current config
eglCheck(eglGetConfigAttrib(m_display, m_config, EGL_DEPTH_SIZE, &tmp));
m_settings.depthBits = tmp;
eglCheck(eglGetConfigAttrib(m_display, m_config, EGL_STENCIL_SIZE, &tmp));
m_settings.stencilBits = tmp;
eglCheck(eglGetConfigAttrib(m_display, m_config, EGL_SAMPLES, &tmp));
m_settings.antialiasingLevel = tmp;
m_settings.majorVersion = 1;
m_settings.minorVersion = 1;
m_settings.attributeFlags = ContextSettings::Default;
}
#ifdef SFML_SYSTEM_LINUX #ifdef SFML_SYSTEM_LINUX
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
XVisualInfo EglContext::selectBestVisual(::Display* XDisplay, unsigned int bitsPerPixel, const ContextSettings& settings) XVisualInfo EglContext::selectBestVisual(::Display* XDisplay, unsigned int bitsPerPixel, const ContextSettings& settings)

View File

@ -165,6 +165,11 @@ public:
private: private:
////////////////////////////////////////////////////////////
/// \brief Helper to copy the picked EGL configuration
////////////////////////////////////////////////////////////
void updateSettings();
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// Member data // Member data
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////