[gtk+] mir, gl: Ensure we use the 3.2 core profile
- From: Marco Trevisan <marcotrevi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] mir, gl: Ensure we use the 3.2 core profile
- Date: Thu, 12 Feb 2015 02:34:37 +0000 (UTC)
commit c82ad2c1292b1e39f41db20467e5b3691cbb6984
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Thu Feb 12 03:34:05 2015 +0100
mir, gl: Ensure we use the 3.2 core profile
Emit an error if the profile is different.
gdk/mir/gdkmirglcontext.c | 44 ++++++++++++++++++++++++++++++++++++++------
1 files changed, 38 insertions(+), 6 deletions(-)
---
diff --git a/gdk/mir/gdkmirglcontext.c b/gdk/mir/gdkmirglcontext.c
index 5cacdb5..b5b23c6 100644
--- a/gdk/mir/gdkmirglcontext.c
+++ b/gdk/mir/gdkmirglcontext.c
@@ -26,6 +26,8 @@
G_DEFINE_TYPE (GdkMirGLContext, gdk_mir_gl_context, GDK_TYPE_GL_CONTEXT)
+#define N_EGL_ATTRS 16
+
static gboolean
gdk_mir_gl_context_realize (GdkGLContext *context,
GError **error)
@@ -35,8 +37,10 @@ gdk_mir_gl_context_realize (GdkGLContext *context,
GdkGLContext *share = gdk_gl_context_get_shared_context (context);
GdkGLProfile profile = gdk_gl_context_get_profile (context);
EGLContext ctx;
- EGLint context_attribs[3];
- int i;
+ EGLint context_attribs[N_EGL_ATTRS];
+ int major, minor, flags;
+ gboolean debug_bit, forward_bit;
+ int i = 0;
if (!_gdk_mir_display_init_egl_display (display))
{
@@ -46,13 +50,41 @@ gdk_mir_gl_context_realize (GdkGLContext *context,
return FALSE;
}
- i = 0;
- if (profile == GDK_GL_PROFILE_3_2_CORE)
+ if (profile != GDK_GL_PROFILE_3_2_CORE)
{
- context_attribs[i++] = EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR;
- context_attribs[i++] = EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR;
+ 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 (_gdk_mir_display_get_egl_display (display),
context_mir->egl_config,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]