diff --git a/src/waffle/glx/glx_config.c b/src/waffle/glx/glx_config.c index 1b5de37..1e3bc47 100644 --- a/src/waffle/glx/glx_config.c +++ b/src/waffle/glx/glx_config.c @@ -60,30 +60,44 @@ glx_config_check_context_attrs(struct glx_display *dpy, assert(wcore_config_attrs_version_ge(attrs, 30)); } - if (attrs->context_debug && !dpy->ARB_create_context) { + if (!dpy->ARB_create_context && + glx_context_needs_arb_create_context(attrs)) { + const char *gl = ""; + const char *fwd_compat = ""; + const char *debug = ""; + const char *robust = ""; + + // XXX: Keep in sync with glx_context_needs_arb_create_context() + if (attrs->context_api != WAFFLE_CONTEXT_OPENGL) + gl = " - a OpenGL ES* context\n"; + else if (wcore_config_attrs_version_ge(attrs, 32)) + gl = " - a OpenGL 3.2+ context\n"; + + if (attrs->context_forward_compatible) + fwd_compat = " - a forward-compatible context\n"; + + if (attrs->context_debug) + debug = " - a debug context\n"; + + if (attrs->context_robust) + robust = " - a robust access context\n"; + wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM, - "GLX_ARB_create_context is required in order to " - "request a debug context"); + "GLX_ARB_create_context is required to create:\n" + "%s%s%s%s", gl, fwd_compat, debug, robust); return false; } if (attrs->context_robust && !dpy->ARB_create_context_robustness) { wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM, - "GLX_ARB_create_context_robustness is required in order to " + "GLX_ARB_create_context_robustness is required to " "request a robust access context"); return false; } switch (attrs->context_api) { case WAFFLE_CONTEXT_OPENGL: - if (glx_context_needs_arb_create_context(attrs) && - !dpy->ARB_create_context) { - wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM, - "GLX_ARB_create_context is required in order to " - "request an OpenGL version greater or equal than 3.2"); - return false; - } - else if (wcore_config_attrs_version_ge(attrs, 32) && !dpy->ARB_create_context_profile) { + if (wcore_config_attrs_version_ge(attrs, 32) && !dpy->ARB_create_context_profile) { wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM, "GLX_ARB_create_context_profile is required " "to create a context with version >= 3.2"); @@ -94,13 +108,6 @@ glx_config_check_context_attrs(struct glx_display *dpy, attrs->context_profile == WAFFLE_CONTEXT_COMPATIBILITY_PROFILE); } - if (attrs->context_forward_compatible && !dpy->ARB_create_context) { - wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM, - "GLX_ARB_create_context is required in order to " - "request a forward-compatible context"); - return false; - } - return true; case WAFFLE_CONTEXT_OPENGL_ES1: diff --git a/src/waffle/glx/glx_context.c b/src/waffle/glx/glx_context.c index a553a6b..0c23ae7 100644 --- a/src/waffle/glx/glx_context.c +++ b/src/waffle/glx/glx_context.c @@ -170,20 +170,15 @@ glx_context_create_native(struct glx_config *config, { GLXContext ctx; GLXContext real_share_ctx = share_ctx ? share_ctx->glx : NULL; + const struct wcore_config_attrs *attrs = &config->wcore.attrs; struct glx_display *dpy = glx_display(config->wcore.display); struct glx_platform *platform = glx_platform(dpy->wcore.platform); - // Use ARB_create_context when we have - // - OpenGL version 1.0, or - // - OpenGL version 3.2 or greater, or - // - OpenGL with fwd_compat, or - // - Debug context - // - // The first one of the four is optional, the remainder hard requirement - // for the use of ARB_create_context. + // Optionally use ARB_create_context for OpenGL 1.0, if available. if (dpy->ARB_create_context && - (wcore_config_attrs_version_eq(&config->wcore.attrs, 10) || - glx_context_needs_arb_create_context(&config->wcore.attrs))) { + (glx_context_needs_arb_create_context(attrs) || + (attrs->context_api == WAFFLE_CONTEXT_OPENGL && + wcore_config_attrs_version_eq(attrs, 10)))) { bool ok; // Choose a large size to prevent accidental overflow. diff --git a/src/waffle/glx/glx_context.h b/src/waffle/glx/glx_context.h index 23ffd74..d3b3645 100644 --- a/src/waffle/glx/glx_context.h +++ b/src/waffle/glx/glx_context.h @@ -58,16 +58,30 @@ union waffle_native_context* glx_context_get_native(struct wcore_context *wc_self); +// XXX: Keep in sync with glx_config_check_context_attrs() static inline bool glx_context_needs_arb_create_context(const struct wcore_config_attrs *attrs) { - if (attrs->context_api == WAFFLE_CONTEXT_OPENGL && - (wcore_config_attrs_version_ge(attrs, 32) || - attrs->context_forward_compatible)) + // Any of the following require the ARB extension, since the data is + // passed as attributes. + + // Using any GLES* profile, + if (attrs->context_api != WAFFLE_CONTEXT_OPENGL) + return true; + + // explicitly requesting OpenGL version (>=3.2), + if (wcore_config_attrs_version_ge(attrs, 32)) + return true; + + // ... or any of the context flags. + if (attrs->context_forward_compatible) return true; if (attrs->context_debug) return true; + if (attrs->context_robust) + return true; + return false; }