+ 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[profile], 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();
+ }