Fixed various linux compile errors in EglContext

This commit is contained in:
James Cowgill 2014-04-21 14:42:07 +01:00
parent f6edb83acd
commit 86b29c539d

View File

@ -27,6 +27,7 @@
// Headers // Headers
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
#include <SFML/Window/EglContext.hpp> #include <SFML/Window/EglContext.hpp>
#include <SFML/Window/WindowImpl.hpp>
#include <SFML/OpenGL.hpp> #include <SFML/OpenGL.hpp>
#include <SFML/System/Err.hpp> #include <SFML/System/Err.hpp>
#include <SFML/System/Sleep.hpp> #include <SFML/System/Sleep.hpp>
@ -35,6 +36,9 @@
#ifdef SFML_SYSTEM_ANDROID #ifdef SFML_SYSTEM_ANDROID
#include <SFML/System/Android/Activity.hpp> #include <SFML/System/Android/Activity.hpp>
#endif #endif
#ifdef SFML_SYSTEM_LINUX
#include <X11/Xlib.h>
#endif
namespace namespace
{ {
@ -46,7 +50,7 @@ namespace
if (display == EGL_NO_DISPLAY) if (display == EGL_NO_DISPLAY)
{ {
eglCheck(eglGetDisplay(EGL_DEFAULT_DISPLAY)); display = eglCheck(eglGetDisplay(EGL_DEFAULT_DISPLAY));
eglCheck(eglInitialize(display, NULL, NULL)); eglCheck(eglInitialize(display, NULL, NULL));
} }
@ -260,12 +264,11 @@ XVisualInfo EglContext::selectBestVisual(::Display* XDisplay, unsigned int bitsP
EGLConfig config = getBestConfig(display, bitsPerPixel, settings); EGLConfig config = getBestConfig(display, bitsPerPixel, settings);
// Retrieve the visual id associated with this EGL config // Retrieve the visual id associated with this EGL config
EGLint nativeVisualId, nativeVisualType; EGLint nativeVisualId;
eglCheck(eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &nativeVisualId)); eglCheck(eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &nativeVisualId));
eglCheck(eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_TYPE, &nativeVisualType));
if (nativeVisualId = 0 && nativeVisualType == EGL_NONE) if (nativeVisualId == 0)
{ {
// Should never happen... // Should never happen...
err() << "No EGL visual found. You should check your graphics driver" << std::endl; err() << "No EGL visual found. You should check your graphics driver" << std::endl;
@ -273,13 +276,14 @@ XVisualInfo EglContext::selectBestVisual(::Display* XDisplay, unsigned int bitsP
return XVisualInfo(); return XVisualInfo();
} }
VisualID visualId = static_cast<VisualID>(nativeVisualId); XVisualInfo vTemplate;
vTemplate.visualid = static_cast<VisualID>(nativeVisualId);
// Get X11 visuals compatible with this EGL config // Get X11 visuals compatible with this EGL config
XVisualInfo *availableVisuals, bestVisual; XVisualInfo *availableVisuals, bestVisual;
int visualCount = 0; int visualCount = 0;
availableVisuals = XGetVisualInfo(XDisplayy, VisualIDMask, &visualId, &visualCount); availableVisuals = XGetVisualInfo(XDisplay, VisualIDMask, &vTemplate, &visualCount);
if (visualCount == 0) if (visualCount == 0)
{ {
@ -290,8 +294,8 @@ XVisualInfo EglContext::selectBestVisual(::Display* XDisplay, unsigned int bitsP
} }
// Pick up the best one // Pick up the best one
bestVisual = availableVisuals[0] bestVisual = availableVisuals[0];
XFree(chosenVisualInfo); XFree(availableVisuals);
return bestVisual; return bestVisual;
} }