Forgot to initialize the EGL display

This commit is contained in:
Jonathan De Wachter 2013-12-29 20:22:07 +01:00
parent 43aa313280
commit 2627c3579f
3 changed files with 33 additions and 4 deletions

View File

@ -36,6 +36,35 @@
#include <SFML/System/Android/Activity.hpp>
#endif
namespace
{
EGLDisplay getInitializedDisplay()
{
#if defined(SFML_SYSTEM_LINUX)
static EGLDisplay display = EGL_NO_DISPLAY;
if (display == EGL_NO_DISPLAY)
{
eglCheck(eglGetDisplay(EGL_DEFAULT_DISPLAY));
eglCheck(eglInitialize(display, NULL, NULL));
}
return display;
#elif defined(SFML_SYSTEM_ANDROID)
// On Android, its native activity handles this for us
sf::priv::ActivityStates* states = sf::priv::getActivity(NULL);
sf::Lock lock(states->mutex);
return states->display;
#endif
}
}
namespace sf
{
namespace priv
@ -47,7 +76,7 @@ m_context (EGL_NO_CONTEXT),
m_surface (EGL_NO_SURFACE)
{
// Get the intialized EGL display
m_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
m_display = getInitializedDisplay();
// Create the EGL surface
const EGLint attribs[] = {
@ -90,7 +119,7 @@ m_surface (EGL_NO_SURFACE)
#endif
// Get the intialized EGL display
m_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
m_display = getInitializedDisplay();
// Create the EGL surface
const EGLint attribs[] = {

View File

@ -165,7 +165,7 @@ XVisualInfo GlxContext::selectBestVisual(::Display* display, unsigned int bitsPe
XVisualInfo* visuals = XGetVisualInfo(display, 0, NULL, &count);
if (visuals)
{
// Evaluate all the returned visuals, and pick the best one1
// Evaluate all the returned visuals, and pick the best one
int bestScore = 0xFFFF;
XVisualInfo bestVisual;
for (int i = 0; i < count; ++i)

View File

@ -83,7 +83,7 @@ m_depthbuffer (0),
m_vsyncEnabled(false),
m_clock ()
{
// This constructor shoult never be used by implementation
// This constructor should never be used by implementation
err() << "Calling bad EaglContext constructor, please contact your developer :)" << std::endl;
}