summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2023-04-19 14:55:14 +0800
committerChun-wei Fan <fanchunwei@src.gnome.org>2023-04-21 11:28:13 +0800
commite11aec3dca8f6b2c498775cb24684c1333aef24e (patch)
tree9237821844271b15d8e902363e0e27b65703db48
parent4355651a3bbe94a9331b8420a90803afaf4351f8 (diff)
downloadgtk+-e11aec3dca8f6b2c498775cb24684c1333aef24e.tar.gz
GDK: Allow forcing OpenGL/ES 3.0 contexts if needed
Allow setting the minimal OpenGL/ES API version to 3.0 if needed, such as when the OpenGL/ES 2.0 context does not support required extensions such as OES_vertex_half_float. Update all callers--this currently does things in the exising way.
-rw-r--r--gdk/gdkglcontext.c18
-rw-r--r--gdk/gdkglcontextprivate.h5
-rw-r--r--gdk/x11/gdkglcontext-glx.c3
3 files changed, 20 insertions, 6 deletions
diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c
index b5850ea71b..6dd673d27c 100644
--- a/gdk/gdkglcontext.c
+++ b/gdk/gdkglcontext.c
@@ -293,7 +293,8 @@ gdk_gl_context_create_actual_egl_context (GdkGLContext *context,
/* We will use the default version matching the context status
* unless the user requested a version which makes sense */
gdk_gl_context_get_matching_version (api, legacy,
- &min_major, &min_minor);
+ &min_major, &min_minor,
+ use_es3);
gdk_gl_context_get_clipped_version (context,
min_major, min_minor,
&major, &minor);
@@ -1004,7 +1005,8 @@ void
gdk_gl_context_get_matching_version (GdkGLAPI api,
gboolean legacy,
int *major,
- int *minor)
+ int *minor,
+ gboolean use_es3)
{
int maj, min;
@@ -1023,8 +1025,16 @@ gdk_gl_context_get_matching_version (GdkGLAPI api,
}
else
{
- maj = GDK_GL_MIN_GLES_VERSION_MAJOR;
- min = GDK_GL_MIN_GLES_VERSION_MINOR;
+ if (use_es3)
+ {
+ maj = GDK_GL_MIN_GLES3_VERSION_MAJOR;
+ min = GDK_GL_MIN_GLES3_VERSION_MINOR;
+ }
+ else
+ {
+ maj = GDK_GL_MIN_GLES_VERSION_MAJOR;
+ min = GDK_GL_MIN_GLES_VERSION_MINOR;
+ }
}
if (major != NULL)
diff --git a/gdk/gdkglcontextprivate.h b/gdk/gdkglcontextprivate.h
index ac20742ea9..5aee50c8af 100644
--- a/gdk/gdkglcontextprivate.h
+++ b/gdk/gdkglcontextprivate.h
@@ -44,6 +44,8 @@ G_BEGIN_DECLS
#define GDK_GL_MIN_GL_LEGACY_VERSION_MINOR (0)
#define GDK_GL_MIN_GLES_VERSION_MAJOR (2)
#define GDK_GL_MIN_GLES_VERSION_MINOR (0)
+#define GDK_GL_MIN_GLES3_VERSION_MAJOR (3)
+#define GDK_GL_MIN_GLES3_VERSION_MINOR (0)
typedef enum {
GDK_GL_NONE = 0,
@@ -137,7 +139,8 @@ void gdk_gl_context_get_clipped_version (GdkGLContext
void gdk_gl_context_get_matching_version (GdkGLAPI api,
gboolean legacy,
int *major,
- int *minor);
+ int *minor,
+ gboolean use_es3);
gboolean gdk_gl_context_has_unpack_subimage (GdkGLContext *context);
void gdk_gl_context_push_debug_group (GdkGLContext *context,
diff --git a/gdk/x11/gdkglcontext-glx.c b/gdk/x11/gdkglcontext-glx.c
index bdcd3042cc..cffc4701a8 100644
--- a/gdk/x11/gdkglcontext-glx.c
+++ b/gdk/x11/gdkglcontext-glx.c
@@ -489,7 +489,8 @@ gdk_x11_context_create_glx_context (GdkGLContext *context,
/* We will use the default version matching the context status
* unless the user requested a version which makes sense */
gdk_gl_context_get_matching_version (api, legacy,
- &min_major, &min_minor);
+ &min_major, &min_minor,
+ FALSE);
gdk_gl_context_get_clipped_version (context, min_major, min_minor,
&major, &minor);