[waffle] [PATCH v2] wgl: don't use ARB_create_context with pre 3.2 contexts
Emil Velikov
emil.l.velikov at gmail.com
Fri Apr 15 22:48:54 UTC 2016
Direct port of previous commit.
v2: The version should be 3.2 and not 3.0 as originally.
Cc: Jose Fonseca <jfonseca at vmware.com>
Cc: Ilia Mirkin <imirkin at alum.mit.edu>
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
src/waffle/wgl/wgl_config.c | 7 ++++---
src/waffle/wgl/wgl_context.c | 12 +++++++++++-
src/waffle/wgl/wgl_context.h | 15 +++++++++++++++
3 files changed, 30 insertions(+), 4 deletions(-)
diff --git a/src/waffle/wgl/wgl_config.c b/src/waffle/wgl/wgl_config.c
index 59a70a6..43bcfa5 100644
--- a/src/waffle/wgl/wgl_config.c
+++ b/src/waffle/wgl/wgl_config.c
@@ -32,6 +32,7 @@
#include "wcore_error.h"
#include "wgl_config.h"
+#include "wgl_context.h"
#include "wgl_display.h"
#include "wgl_error.h"
#include "wgl_platform.h"
@@ -73,11 +74,11 @@ wgl_config_check_context_attrs(struct wgl_display *dpy,
switch (attrs->context_api) {
case WAFFLE_CONTEXT_OPENGL:
- if (!wcore_config_attrs_version_eq(attrs, 10) && !dpy->ARB_create_context) {
+ if (wgl_context_needs_arb_create_context(attrs) &&
+ !dpy->ARB_create_context) {
wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM,
"WGL_ARB_create_context is required in order to "
- "request an OpenGL version not equal to the default "
- "value 1.0");
+ "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) {
diff --git a/src/waffle/wgl/wgl_context.c b/src/waffle/wgl/wgl_context.c
index dd45f81..32b2e2d 100644
--- a/src/waffle/wgl/wgl_context.c
+++ b/src/waffle/wgl/wgl_context.c
@@ -152,7 +152,17 @@ wgl_context_create_native(struct wgl_config *config,
HGLRC real_share_ctx = share_ctx ? share_ctx->hglrc : NULL;
HGLRC hglrc;
- if (dpy->ARB_create_context) {
+ // 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.
+ if (dpy->ARB_create_context &&
+ (wcore_config_attrs_version_eq(&config->wcore.attrs, 10) ||
+ wgl_context_needs_arb_create_context(&config->wcore.attrs))) {
bool ok;
// Choose a large size to prevent accidental overflow.
diff --git a/src/waffle/wgl/wgl_context.h b/src/waffle/wgl/wgl_context.h
index c55ad58..28c25c9 100644
--- a/src/waffle/wgl/wgl_context.h
+++ b/src/waffle/wgl/wgl_context.h
@@ -27,6 +27,7 @@
#include <stdbool.h>
+#include "wcore_config_attrs.h"
#include "wcore_context.h"
#include "wcore_util.h"
@@ -51,3 +52,17 @@ wgl_context_create(struct wcore_platform *wc_plat,
bool
wgl_context_destroy(struct wcore_context *wc_self);
+
+static inline bool
+wgl_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))
+ return true;
+
+ if (attrs->context_debug)
+ return true;
+
+ return false;
+}
--
2.8.0
More information about the waffle
mailing list