+ /* The EGL 1.4 spec says:
+ *
+ * "attribute EGL_CONTEXT_CLIENT_VERSION is only valid when the
+ * current rendering API is EGL_OPENGL_ES_API"
+ *
+ * The EGL_KHR_create_context spec says:
+ *
+ * "EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098
+ * (this token is an alias for EGL_CONTEXT_CLIENT_VERSION)"
+ *
+ * "The values for attributes EGL_CONTEXT_MAJOR_VERSION_KHR and
+ * EGL_CONTEXT_MINOR_VERSION_KHR specify the requested client API
+ * version. They are only meaningful for OpenGL and OpenGL ES
+ * contexts, and specifying them for other types of contexts will
+ * generate an error."
+ */
+ if ((api != EGL_OPENGL_ES_API &&
+ (!dpy->Extensions.KHR_create_context || api != EGL_OPENGL_API))) {
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+
+ ctx->ClientMajorVersion = val;
+ break;
+
+ case EGL_CONTEXT_MINOR_VERSION_KHR:
+ /* The EGL_KHR_create_context spec says:
+ *
+ * "The values for attributes EGL_CONTEXT_MAJOR_VERSION_KHR and
+ * EGL_CONTEXT_MINOR_VERSION_KHR specify the requested client API
+ * version. They are only meaningful for OpenGL and OpenGL ES
+ * contexts, and specifying them for other types of contexts will
+ * generate an error."
+ */
+ if (!dpy->Extensions.KHR_create_context ||
+ (api != EGL_OPENGL_ES_API && api != EGL_OPENGL_API)) {
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+
+ ctx->ClientMinorVersion = val;
+ break;
+
+ case EGL_CONTEXT_FLAGS_KHR:
+ if (!dpy->Extensions.KHR_create_context) {
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+
+ /* The EGL_KHR_create_context spec says:
+ *
+ * "Flags are only defined for OpenGL context creation, and
+ * specifying a flags value other than zero for other types of
+ * contexts, including OpenGL ES contexts, will generate an
+ * error."
+ */
+ if (api != EGL_OPENGL_API && val != 0) {
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+
+ ctx->Flags |= val;
+ break;
+
+ case EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR:
+ if (!dpy->Extensions.KHR_create_context) {
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+
+ /* The EGL_KHR_create_context spec says:
+ *
+ * "[EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR] is only meaningful for
+ * OpenGL contexts, and specifying it for other types of
+ * contexts, including OpenGL ES contexts, will generate an
+ * error."
+ */
+ if (api != EGL_OPENGL_API) {
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+
+ ctx->Profile = val;
+ break;
+
+ case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR:
+ /* The EGL_KHR_create_context spec says:
+ *
+ * "[EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR] is only
+ * meaningful for OpenGL contexts, and specifying it for other
+ * types of contexts, including OpenGL ES contexts, will generate
+ * an error."
+ */
+ if (!dpy->Extensions.KHR_create_context
+ || api != EGL_OPENGL_API) {
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+
+ ctx->ResetNotificationStrategy = val;
+ break;
+
+ case EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT:
+ /* The EGL_EXT_create_context_robustness spec says:
+ *
+ * "[EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT] is only
+ * meaningful for OpenGL ES contexts, and specifying it for other
+ * types of contexts will generate an EGL_BAD_ATTRIBUTE error."
+ */
+ if (!dpy->Extensions.EXT_create_context_robustness
+ || api != EGL_OPENGL_ES_API) {
+ err = EGL_BAD_ATTRIBUTE;
+ break;
+ }
+
+ ctx->ResetNotificationStrategy = val;
+ break;
+
+ case EGL_CONTEXT_OPENGL_ROBUST_ACCESS_EXT:
+ if (!dpy->Extensions.EXT_create_context_robustness) {