add_dependencies (egltrace glproc)
- set_property (
- TARGET egltrace
- APPEND
- PROPERTY COMPILE_DEFINITIONS "TRACE_EGL"
- )
-
set_target_properties (egltrace PROPERTIES
# avoid the default "lib" prefix
PREFIX ""
TARGET eglretrace
APPEND
PROPERTY COMPILE_DEFINITIONS "RETRACE"
- PROPERTY COMPILE_DEFINITIONS "TRACE_EGL"
)
target_link_libraries (eglretrace
print '#include "glimports.hpp"'
print '#include "os.hpp"'
print
- print
dispatcher = GlDispatcher()
+ print
dispatcher.header()
- print '#if defined(TRACE_EGL)'
print
dispatcher.dispatch_api(eglapi)
- print '#elif defined(_WIN32)'
+ print
+ print '#if defined(_WIN32)'
print
dispatcher.dispatch_api(wglapi)
+ print
print '#elif defined(__APPLE__)'
+ print
dispatcher.dispatch_api(cglapi)
+ print
print '#else'
print
dispatcher.dispatch_api(glxapi)
+ print
print '#endif'
print
dispatcher.dispatch_api(glapi)
#include "glstate_internal.hpp"
+#ifdef __linux__
+#include <dlfcn.h>
+#endif
+
#ifdef __APPLE__
#include <Carbon/Carbon.h>
static bool
getDrawableBounds(GLint *width, GLint *height) {
-#if defined(TRACE_EGL)
+#if defined(__linux__)
+ if (dlsym(RTLD_DEFAULT, "eglGetCurrentContext")) {
+ EGLContext currentContext = eglGetCurrentContext();
+ if (currentContext == EGL_NO_CONTEXT) {
+ return false;
+ }
- EGLContext currentContext = eglGetCurrentContext();
- if (currentContext == EGL_NO_CONTEXT) {
- return false;
- }
+ 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;
}
+#endif
- return true;
-
-#elif defined(_WIN32)
+#if defined(_WIN32)
HDC hDC = wglGetCurrentDC();
if (!hDC) {