GdkGLContext: set_allowed_apis does not work
I tired doing some custom widget implementation that uses gdk_gl_context_set_allowed_apis
to request either OpenGL or GLES (depending on my app needs). Unfortunately, this API does not seem to work, as I always end up with OpenGL (not ES) for some reason.
I am also able to reproduce the same behavior with GLArea that has set_use_es
function (which calls gdk_gl_context_set_allowed_apis
internally), so here is my reproducer for this:
#include <gtk/gtk.h>
static void
activate (GtkApplication *app, gpointer user_data)
{
GtkWidget *window = gtk_application_window_new (app);
GtkWidget *widget = gtk_gl_area_new ();
gtk_gl_area_set_use_es (GTK_GL_AREA (widget), TRUE);
gtk_window_set_child (GTK_WINDOW (window), widget);
gtk_window_present (GTK_WINDOW (window));
}
void
main (int argc, char **argv)
{
GtkApplication *app = gtk_application_new ("org.gtk.example", G_APPLICATION_FLAGS_NONE);
g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
g_application_run (G_APPLICATION (app), argc, argv);
g_object_unref (app);
}
GDK_DEBUG=opengl ./example
:
Output of Gdk-Message: 11:11:47.092: EGL API version 1.5 found
- Vendor: Mesa Project
- Version: 1.5
- Client APIs: OpenGL OpenGL_ES
- Extensions:
EGL_ANDROID_blob_cache
EGL_EXT_buffer_age
EGL_EXT_create_context_robustness
EGL_EXT_image_dma_buf_import
EGL_EXT_image_dma_buf_import_modifiers
EGL_EXT_pixel_format_float
EGL_EXT_present_opaque
EGL_EXT_swap_buffers_with_damage
EGL_KHR_cl_event2
EGL_KHR_config_attribs
EGL_KHR_create_context
EGL_KHR_create_context_no_error
EGL_KHR_fence_sync
EGL_KHR_get_all_proc_addresses
EGL_KHR_gl_colorspace
EGL_KHR_gl_renderbuffer_image
EGL_KHR_gl_texture_2D_image
EGL_KHR_gl_texture_3D_image
EGL_KHR_gl_texture_cubemap_image
EGL_KHR_image_base
EGL_KHR_no_config_context
EGL_KHR_reusable_sync
EGL_KHR_surfaceless_context
EGL_KHR_swap_buffers_with_damage
EGL_KHR_wait_sync
EGL_MESA_configless_context
EGL_MESA_drm_image
EGL_MESA_image_dma_buf_export
EGL_MESA_query_driver
EGL_WL_bind_wayland_display
EGL_WL_create_wayland_buffer_from_image
- Selected fbconfig: R8G8B8A8
high depth: none
Gdk-Message: 11:11:47.092: Creating EGL context version 3.2 (debug:no, forward:no, legacy:no, es:no)
Gdk-Message: 11:11:47.093: Created EGL context[0xd38cd0]
Using OpenGL backend EGL
Gdk-Message: 11:11:47.094: Creating EGL context version 3.2 (debug:no, forward:no, legacy:no, es:no)
Gdk-Message: 11:11:47.094: Created EGL context[0xd39550]
Gdk-Message: 11:11:47.097: OpenGL version: 4.3 (core)
* GLSL version: 4.30
* Extensions checked:
- GL_KHR_debug: yes
- GL_EXT_unpack_subimage: yes
Gdk-Message: 11:11:47.120: OpenGL version: 4.3 (core)
* GLSL version: 4.30
* Extensions checked:
- GL_KHR_debug: yes
- GL_EXT_unpack_subimage: yes
Gdk-Message: 11:11:47.120: Creating EGL context version 3.2 (debug:no, forward:no, legacy:no, es:no)
Gdk-Message: 11:11:47.121: Created EGL context[0x15aecd0]
Gdk-Message: 11:11:47.154: OpenGL version: 4.3 (core)
* GLSL version: 4.30
* Extensions checked:
- GL_KHR_debug: yes
- GL_EXT_unpack_subimage: yes
GDK_DEBUG=opengl,gl-gles ./example
:
On the other hand if I use Gdk-Message: 11:12:51.402: EGL API version 1.5 found
- Vendor: Mesa Project
- Version: 1.5
- Client APIs: OpenGL OpenGL_ES
- Extensions:
EGL_ANDROID_blob_cache
EGL_EXT_buffer_age
EGL_EXT_create_context_robustness
EGL_EXT_image_dma_buf_import
EGL_EXT_image_dma_buf_import_modifiers
EGL_EXT_pixel_format_float
EGL_EXT_present_opaque
EGL_EXT_swap_buffers_with_damage
EGL_KHR_cl_event2
EGL_KHR_config_attribs
EGL_KHR_create_context
EGL_KHR_create_context_no_error
EGL_KHR_fence_sync
EGL_KHR_get_all_proc_addresses
EGL_KHR_gl_colorspace
EGL_KHR_gl_renderbuffer_image
EGL_KHR_gl_texture_2D_image
EGL_KHR_gl_texture_3D_image
EGL_KHR_gl_texture_cubemap_image
EGL_KHR_image_base
EGL_KHR_no_config_context
EGL_KHR_reusable_sync
EGL_KHR_surfaceless_context
EGL_KHR_swap_buffers_with_damage
EGL_KHR_wait_sync
EGL_MESA_configless_context
EGL_MESA_drm_image
EGL_MESA_image_dma_buf_export
EGL_MESA_query_driver
EGL_WL_bind_wayland_display
EGL_WL_create_wayland_buffer_from_image
- Selected fbconfig: R8G8B8A8
high depth: none
Gdk-Message: 11:12:51.402: Creating EGL context version 2.0 (debug:no, forward:no, legacy:no, es:yes)
Gdk-Message: 11:12:51.403: Created EGL context[0x21d4bb0]
Using OpenGL backend EGL
Gdk-Message: 11:12:51.403: Creating EGL context version 2.0 (debug:no, forward:no, legacy:no, es:yes)
Gdk-Message: 11:12:51.404: Created EGL context[0x21bf300]
Gdk-Message: 11:12:51.408: OpenGL ES version: 3.1 (core)
* GLSL version: OpenGL ES GLSL ES 3.10
* Extensions checked:
- GL_KHR_debug: yes
- GL_EXT_unpack_subimage: yes
Gdk-Message: 11:12:51.432: OpenGL ES version: 3.1 (core)
* GLSL version: OpenGL ES GLSL ES 3.10
* Extensions checked:
- GL_KHR_debug: yes
- GL_EXT_unpack_subimage: yes
Gdk-Message: 11:12:51.434: Creating EGL context version 2.0 (debug:no, forward:no, legacy:no, es:yes)
Gdk-Message: 11:12:51.434: Created EGL context[0x2a369d0]
Gdk-Message: 11:12:51.470: OpenGL ES version: 3.1 (core)
* GLSL version: OpenGL ES GLSL ES 3.10
* Extensions checked:
- GL_KHR_debug: yes
- GL_EXT_unpack_subimage: yes
When forced, GLES is correctly initialized, so my HW is capable of using it just fine. Only the gdk_gl_context_set_allowed_apis
with GDK_GL_API_GLES
does not seem to have any effect here.
This was tested using GTK4 build from latest git main (after 4.6.1 ver), linux, GNOME Shell, Wayland session.
Edited by Rafał Dzięgiel