[gtk+/wip/ebassi/gl-context-realize] wayland/gl: Ensure we use the 3.2 core profile
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/ebassi/gl-context-realize] wayland/gl: Ensure we use the 3.2 core profile
- Date: Mon, 9 Feb 2015 16:33:24 +0000 (UTC)
commit c4df6af425b56706b1b5b30780092ee223bdf834
Author: Emmanuele Bassi <ebassi gnome org>
Date: Mon Feb 9 15:56:18 2015 +0000
wayland/gl: Ensure we use the 3.2 core profile
Emit an error if the profile is different.
https://bugzilla.gnome.org/show_bug.cgi?id=741946
gdk/wayland/gdkglcontext-wayland.c | 64 +++++++++++++++++++++--------------
1 files changed, 38 insertions(+), 26 deletions(-)
---
diff --git a/gdk/wayland/gdkglcontext-wayland.c b/gdk/wayland/gdkglcontext-wayland.c
index fbdb02a..5f3ddfb 100644
--- a/gdk/wayland/gdkglcontext-wayland.c
+++ b/gdk/wayland/gdkglcontext-wayland.c
@@ -100,6 +100,8 @@ gdk_wayland_window_invalidate_for_new_frame (GdkWindow *window,
}
}
+#define N_EGL_ATTRS 16
+
static gboolean
gdk_wayland_gl_context_realize (GdkGLContext *context,
GError **error)
@@ -110,36 +112,46 @@ gdk_wayland_gl_context_realize (GdkGLContext *context,
GdkGLProfile profile = gdk_gl_context_get_profile (context);
GdkWaylandDisplay *display_wayland = GDK_WAYLAND_DISPLAY (display);
EGLContext ctx;
- EGLint context_attribs[16];
- int i;
+ EGLint context_attribs[N_EGL_ATTRS];
+ int major, minor, flags;
+ gboolean debug_bit, forward_bit;
+ int i = 0;
- i = 0;
- if (profile == GDK_GL_PROFILE_3_2_CORE)
+ if (profile != GDK_GL_PROFILE_3_2_CORE)
{
- int major, minor, flags;
- gboolean debug_bit, forward_bit;
-
- gdk_gl_context_get_required_version (context, &major, &minor);
- debug_bit = gdk_gl_context_get_debug_enabled (context);
- forward_bit = gdk_gl_context_get_forward_compatible (context);
-
- flags = 0;
-
- if (debug_bit)
- flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
- if (forward_bit)
- flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
-
- context_attribs[i++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
- context_attribs[i++] = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
- context_attribs[i++] = EGL_CONTEXT_MAJOR_VERSION_KHR;
- context_attribs[i++] = major;
- context_attribs[i++] = EGL_CONTEXT_MINOR_VERSION_KHR;
- context_attribs[i++] = minor;
- context_attribs[i++] = EGL_CONTEXT_FLAGS_KHR;
- context_attribs[i++] = flags;
+ g_set_error_literal (error, GDK_GL_ERROR,
+ GDK_GL_ERROR_UNSUPPORTED_PROFILE,
+ _("Unsupported profile for a GL context"));
+ return FALSE;
}
+
+ gdk_gl_context_get_required_version (context, &major, &minor);
+ debug_bit = gdk_gl_context_get_debug_enabled (context);
+ forward_bit = gdk_gl_context_get_forward_compatible (context);
+
+ flags = 0;
+
+ if (debug_bit)
+ flags |= EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR;
+ if (forward_bit)
+ flags |= EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR;
+
+ /* We want a core profile */
+ context_attribs[i++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
+ context_attribs[i++] = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
+
+ /* Specify the version */
+ context_attribs[i++] = EGL_CONTEXT_MAJOR_VERSION_KHR;
+ context_attribs[i++] = major;
+ context_attribs[i++] = EGL_CONTEXT_MINOR_VERSION_KHR;
+ context_attribs[i++] = minor;
+
+ /* Specify the flags */
+ context_attribs[i++] = EGL_CONTEXT_FLAGS_KHR;
+ context_attribs[i++] = flags;
+
context_attribs[i++] = EGL_NONE;
+ g_assert (i < N_EGL_ATTRS);
ctx = eglCreateContext (display_wayland->egl_display,
context_wayland->egl_config,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]