GdkGLContext: use_es flag is ignored
Steps to reproduce
- Create a GtkGLarea and call
gtk_gl_area_set_use_es(..., 1)
- Realize the widget, then check the result of
gtk_gl_area_get_use_es()
Current behavior
Unless run on a device that only supports OpenGL ES, not the "full" version, gtk_gl_area_get_use_es
and gdk_gl_context_get_use_es
always return false, and a non-ES context is created.
Expected outcome
GDK should try to create an ES context if the user requests it with gtk_gl_area_set_use_es
. If that's not what it's supposed to do, why make gtk_gl_area_set_use_es
and gdk_gl_context_set_use_es
public?
Version information
This is confirmed in GTK 3.24.30 and 4.4.0 on Arch Linux, with GNOME on Wayland, but I think Xorg is also affected.
Additional information
The reason for this can be seen by examining gdk_wayland_gl_context_realize
. It does this:
use_es = GDK_DISPLAY_DEBUG_CHECK (display, GL_GLES) ||
(share != NULL && gdk_gl_context_get_use_es (share));
So for a start, it's trying to check the use_es flag of the display's shared context instead of the context being created. Additionally, gdk_gl_context_set_use_es
can only be called before the context is realized, and gdk_gl_context_get_use_es
always returns false if the context doesn't have its realized flag (in the GdkGLContext base class) set. The realized flag doesn't get set until after the realize virtual function returns. So gdk_gl_context_get_use_es
can never return true on a system that supports non-ES OpenGL.