diff options
author | José Fonseca <jfonseca@vmware.com> | 2014-02-28 14:17:35 +0000 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2014-02-28 14:17:35 +0000 |
commit | 9a2e56819def9093693bca6896cbfeef9a5950d2 (patch) | |
tree | ba19dc3e6c68a5c4d91fee01adf79f6663ac4fa1 /retrace/glws_egl_xlib.cpp | |
parent | c24f98f8356103a5999c14fbf382b3c8b3de29dd (diff) |
eglretrace: Support non-compat GL profiles and debug contexts.
Not really tested though, as I don't have an EGL_KHR_create_context
implementation readily available.
Diffstat (limited to 'retrace/glws_egl_xlib.cpp')
-rw-r--r-- | retrace/glws_egl_xlib.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/retrace/glws_egl_xlib.cpp b/retrace/glws_egl_xlib.cpp index 9bd7f798..e51078dd 100644 --- a/retrace/glws_egl_xlib.cpp +++ b/retrace/glws_egl_xlib.cpp @@ -40,6 +40,8 @@ namespace glws { static Display *display = NULL; static EGLDisplay eglDisplay = EGL_NO_DISPLAY; +static char const *eglExtensions = NULL; +static bool has_EGL_KHR_create_context = false; static int screen = 0; @@ -305,6 +307,9 @@ init(void) { XCloseDisplay(display); exit(1); } + + eglExtensions = eglQueryString(eglDisplay, EGL_EXTENSIONS); + has_EGL_KHR_create_context = checkExtension("EGL_KHR_create_context", eglExtensions); } void @@ -350,6 +355,11 @@ createVisual(bool doubleBuffer, unsigned samples, Profile profile) { const EGLint *api_bits; switch(profile) { + default: + if (!has_EGL_KHR_create_context) { + return NULL; + } + /* pass-through */ case PROFILE_COMPAT: api_bits = api_bits_gl; break; @@ -359,8 +369,6 @@ createVisual(bool doubleBuffer, unsigned samples, Profile profile) { case PROFILE_ES2: api_bits = api_bits_gles2; break; - default: - return NULL; }; for (int i = 0; i < 7; i++) { @@ -430,7 +438,22 @@ createContext(const Visual *_visual, Context *shareContext, bool debug) attribs.add(EGL_CONTEXT_CLIENT_VERSION, 2); break; default: - return NULL; + if (has_EGL_KHR_create_context) { + unsigned major, minor; + bool core; + getProfileVersion(profile, major, minor, core); + attribs.add(EGL_CONTEXT_MAJOR_VERSION_KHR, major); + attribs.add(EGL_CONTEXT_MINOR_VERSION_KHR, minor); + if (core) { + attribs.add(EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR); + } + } else { + return NULL; + } + } + + if (debug && has_EGL_KHR_create_context) { + attribs.add(EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR); } attribs.end(EGL_NONE); |