diff options
author | José Fonseca <jfonseca@vmware.com> | 2013-10-30 11:45:47 +0000 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2013-10-30 11:45:47 +0000 |
commit | 984010aac97b628d390dce6fecb8197eadfabb47 (patch) | |
tree | 47d243c3ac033382814db368a1de058746e5e307 /retrace/glretrace_glx.cpp | |
parent | 3ee3cd4ca0970320b0a05137cb54fc4994e0bce9 (diff) |
glretrace: Support more profiles; match the profile used in glXCreateContextAttribsARBG call.
Should fix issue #176.
Diffstat (limited to 'retrace/glretrace_glx.cpp')
-rw-r--r-- | retrace/glretrace_glx.cpp | 60 |
1 files changed, 54 insertions, 6 deletions
diff --git a/retrace/glretrace_glx.cpp b/retrace/glretrace_glx.cpp index 7efc3bf3..93ad47bd 100644 --- a/retrace/glretrace_glx.cpp +++ b/retrace/glretrace_glx.cpp @@ -28,14 +28,23 @@ #include "retrace.hpp" #include "glretrace.hpp" +#if !defined(HAVE_X11) -#ifndef GLX_PBUFFER_HEIGHT #define GLX_PBUFFER_HEIGHT 0x8040 -#endif - -#ifndef GLX_PBUFFER_WIDTH #define GLX_PBUFFER_WIDTH 0x8041 -#endif + +#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define GLX_CONTEXT_FLAGS_ARB 0x2094 +#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 + +#define GLX_CONTEXT_DEBUG_BIT_ARB 0x0001 +#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 + +#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 +#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 + +#endif /* !HAVE_X11 */ using namespace glretrace; @@ -89,7 +98,46 @@ static void retrace_glXCreateContextAttribsARB(trace::Call &call) { unsigned long long orig_context = call.ret->toUIntPtr(); Context *share_context = getContext(call.arg(2).toUIntPtr()); - Context *context = glretrace::createContext(share_context); + unsigned major = 1; + unsigned minor = 0; + bool core = false; + + const trace::Array * attribs = call.arg(4).toArray(); + if (attribs) { + size_t i = 0; + while (i < attribs->values.size()) { + int param = attribs->values[i++]->toSInt(); + if (param == 0) { + break; + } + int value = attribs->values[i++]->toSInt(); + + switch (param) { + case GLX_CONTEXT_MAJOR_VERSION_ARB: + major = value; + break; + case GLX_CONTEXT_MINOR_VERSION_ARB: + minor = value; + break; + case GLX_CONTEXT_FLAGS_ARB: + break; + case GLX_CONTEXT_PROFILE_MASK_ARB: + if (value & GLX_CONTEXT_CORE_PROFILE_BIT_ARB) { + core = true; + } + break; + default: + break; + } + } + } + + glws::Profile profile = glws::PROFILE_COMPAT; + if (major >= 3) { + profile = (glws::Profile)((core ? 0x100 : 0) | (major << 4) | minor); + } + + Context *context = glretrace::createContext(share_context, profile); context_map[orig_context] = context; } |