summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChia-I Wu <olvaffe@gmail.com>2011-11-08 14:31:58 -0700
committerJosé Fonseca <jose.r.fonseca@gmail.com>2011-11-17 15:50:26 +0000
commit86bf7e20eef9daf8944d0f3882e8ef429131a87c (patch)
tree542268e1f83306221cd8185b661bf6c4061cb6bf
parentd441973ddac60f5ec3e4a44da734ce1112e6eb81 (diff)
gles: Fix retrace of eglCreateContext for GLES contexts
Check the current API and the attribute list to determine the profile of the context.
-rw-r--r--glretrace_egl.cpp54
1 files changed, 47 insertions, 7 deletions
diff --git a/glretrace_egl.cpp b/glretrace_egl.cpp
index 1c7697a..4e549a3 100644
--- a/glretrace_egl.cpp
+++ b/glretrace_egl.cpp
@@ -37,6 +37,7 @@
#define EGL_OPENGL_ES_API 0x30A0
#define EGL_OPENVG_API 0x30A1
#define EGL_OPENGL_API 0x30A2
+#define EGL_CONTEXT_CLIENT_VERSION 0x3098
#endif
@@ -98,16 +99,55 @@ static void retrace_eglBindAPI(trace::Call &call) {
}
static void retrace_eglCreateContext(trace::Call &call) {
- if (current_api != EGL_OPENGL_API) {
- retrace::warning(call) << "only OpenGL is supported. Aborting...\n";
- os::abort();
- return;
- }
-
unsigned long long orig_context = call.ret->toUIntPtr();
glws::Context *share_context = getContext(call.arg(2).toUIntPtr());
+ trace::Array *attrib_array = dynamic_cast<trace::Array *>(&call.arg(3));
+ glws::Profile profile;
+
+ switch (current_api) {
+ case EGL_OPENGL_API:
+ profile = glws::PROFILE_COMPAT;
+ break;
+ case EGL_OPENGL_ES_API:
+ default:
+ profile = glws::PROFILE_ES1;
+ if (attrib_array) {
+ for (int i = 0; i < attrib_array->values.size(); i += 2) {
+ int v = attrib_array->values[i]->toSInt();
+ if (v == EGL_CONTEXT_CLIENT_VERSION) {
+ v = attrib_array->values[i + 1]->toSInt();
+ if (v == 2)
+ profile = glws::PROFILE_ES2;
+ break;
+ }
+ }
+ }
+ break;
+ }
+
+
+ glws::Context *context = glws::createContext(glretrace::visual, share_context, profile);
+ if (!context) {
+ const char *name;
+ switch (profile) {
+ case glws::PROFILE_COMPAT:
+ name = "OpenGL";
+ break;
+ case glws::PROFILE_ES1:
+ name = "OpenGL ES 1.1";
+ break;
+ case glws::PROFILE_ES2:
+ name = "OpenGL ES 2.0";
+ break;
+ default:
+ name = "unknown";
+ break;
+ }
+
+ retrace::warning(call) << "Failed to create " << name << " context.\n";
+ os::abort();
+ }
- glws::Context *context = glws::createContext(glretrace::visual, share_context);
context_map[orig_context] = context;
}