From 3941d9f80df99d47579b2619d36b61f8cc7ec3c3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Fonseca?= Date: Sun, 28 Apr 2013 22:32:27 +0100 Subject: [PATCH] glstate: Fallback to GLX when there is no current EGL context (issue #124). --- retrace/glstate_images.cpp | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/retrace/glstate_images.cpp b/retrace/glstate_images.cpp index ad60486..b95b8cc 100644 --- a/retrace/glstate_images.cpp +++ b/retrace/glstate_images.cpp @@ -518,26 +518,24 @@ getDrawableBounds(GLint *width, GLint *height) { #if defined(__linux__) if (dlsym(RTLD_DEFAULT, "eglGetCurrentContext")) { EGLContext currentContext = eglGetCurrentContext(); - if (currentContext == EGL_NO_CONTEXT) { - return false; - } + if (currentContext != EGL_NO_CONTEXT) { + EGLSurface currentSurface = eglGetCurrentSurface(EGL_DRAW); + if (currentSurface == EGL_NO_SURFACE) { + return false; + } - EGLSurface currentSurface = eglGetCurrentSurface(EGL_DRAW); - if (currentSurface == EGL_NO_SURFACE) { - return false; - } + EGLDisplay currentDisplay = eglGetCurrentDisplay(); + if (currentDisplay == EGL_NO_DISPLAY) { + return false; + } - EGLDisplay currentDisplay = eglGetCurrentDisplay(); - if (currentDisplay == EGL_NO_DISPLAY) { - return false; - } + if (!eglQuerySurface(currentDisplay, currentSurface, EGL_WIDTH, width) || + !eglQuerySurface(currentDisplay, currentSurface, EGL_HEIGHT, height)) { + return false; + } - if (!eglQuerySurface(currentDisplay, currentSurface, EGL_WIDTH, width) || - !eglQuerySurface(currentDisplay, currentSurface, EGL_HEIGHT, height)) { - return false; + return true; } - - return true; } #endif -- 2.43.0