Hi, @ebassi
I add these code after gl_area = gtk_gl_area_new ()
in main function
and replace epoxy/gl.h
with epoxy/egl.h
GdkGLContext *context;
gtk_gl_area_set_use_es (GTK_GL_AREA (gl_area), TRUE);
context = gtk_gl_area_get_context (GTK_GL_AREA (gl_area));
gdk_gl_context_set_use_es (context, TRUE);
gdk_gl_context_set_debug_enabled (context, TRUE);
It return
(a.out:12769): Gdk-CRITICAL **: 11:52:43.145: gdk_gl_context_set_use_es: assertion 'GDK_IS_GL_CONTEXT (context)' failed
(a.out:12769): Gdk-CRITICAL **: 11:52:43.145: gdk_gl_context_set_debug_enabled: assertion 'GDK_IS_GL_CONTEXT (context)' failed
Does this help clarify the issue?
ebassi
(Emmanuele Bassi)
July 11, 2024, 9:54am
22
Not really, unfortunately; you’re calling gtk_gl_area_get_context()
right after creating the widget, but the function will return NULL
until the widget is realized. You need to call gtk_widget_realize (gl_area)
before calling gtk_gl_area_get_context()
.
It won’t really help much, because we know from the error displayed in the GLArea widget that the context creation failed. That’s why I asked for the debugging output.
The problem is definitely related to your environment: GTK and the demo you are using are going to be fairly different. GTK does not link directly to whatever OpenGL implementation is available: it uses libepoxy to dynamically load the appropriate library.
Since we’re flying blind, here, I guess I’ll have to start asking what kind of system you’re using:
are you using X11?
if you’re using X11, does your platform have a GLX driver?
@ebassi
I’m x11 system, and my platform have a EGL driver ( Is this workable? )
lb90
July 16, 2024, 8:12pm
24
Hi @nfv6867sr ,
I may be wrong, but I think that GTK3 supports only GLX on X11. Just grep for egl
in gdk/ , you’ll see code in wayland/ and win32/ subdirectories.
Hi, @ebassi
I finally solved the debugging output.
Here are the information.
root@am62xx-evm:/run/media/sda1# GDK_DEBUG=opengl ./a.out
(a.out:3487): Gdk-CRITICAL **: 00:08:21.458: gdk_seat_get_keyboard: assertion 'GDK_IS_SEAT (seat)' failed
Gdk-Message: 00:08:22.086: EGL API version 1.5 found
- Vendor: Mesa Project
- Version: 1.5
- Client APIs: OpenGL_ES
- Extensions:
EGL_ANDROID_native_fence_sync EGL_EXT_buffer_age EGL_EXT_create_context_robustness EGL_EXT_image_dma_buf_import EGL_EXT_image_dma_buf_import_modifiers EGL_EXT_image_gl_colorspace EGL_EXT_present_opaque EGL_EXT_swap_buffers_with_damage EGL_EXT_yuv_surface EGL_IMG_context_priority EGL_KHR_cl_event2 EGL_KHR_config_attribs EGL_KHR_create_context 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_partial_update EGL_KHR_reusable_sync EGL_KHR_surfaceless_context EGL_KHR_swap_buffers_with_damage EGL_EXT_pixel_format_float 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 EGL_IMG_cl_image
Gdk-Message: 00:08:22.087: Creating EGL context version 3.2 (debug:no, forward:no, legacy:no, es:no)
Gdk-Message: 00:08:22.087: eglCreateContext failed, switching to legacy
Hi @lb90 ,
I wonder if my embedded system is x11, should I use GLX or EGL driver?
lb90
July 17, 2024, 12:09pm
27
Both are quite good. EGL is newer and has support for nice things, see Prefer EGL to GLX for the GL support on X11 (!3540) · Merge requests · GNOME / gtk · GitLab . On the other hand, older projects do not support EGL, only GLX.
See also:
Hi, @ebassi
You mean gtk_gl_area_set_use_es
might not work? Unless we use GDK_GL=gles
( BTW, I can’t find this environment variable on Gtk – 3.0: Running GTK Applications or Gtk – 4.0: Running and debugging GTK Applications Is it equivalent to GDK_DEBUG=gl-disable-gl
)
Thanks~
ebassi
(Emmanuele Bassi)
July 19, 2024, 12:58pm
29
Correct: GLES support is optional, at all levels.
Yes, it’s missing from the GTK3 documentation; please, file an issue.
GTK4 does not have that environment variable, and it has been replaced by the corresponding GDK_DEBUG
options; but GTK4 is also using GLES by default after 4.14.
Hi @ebassi ,
Recently I found that my environment can run this code Bob's development blog: Using EGL with GTK+
I’d like to know if GLArea defaults to using GLX or EGL? My X11 embedded system only has EGL. Is there any way to force the use of EGL?
We can set GDK_DEBUG=gl-egl
in GTK4, but how to set it in GTK3?
Hi @ebassi ,
Is this issue Support EGL for creating GL contexts on X11 (#738) · Issues · GNOME / gtk · GitLab also fixed in GTK3? If so, how to force the use of EGL on x11 by environment variables?
Thanks!
Hi @ebassi ,
I found that, in GTK3 source code, gtk/gdk/x11/gdkglcontext-x11.c only support GLX, while in GTK4 source code, gtk/gdk/x11/gdkglcontext-glx.c is used for GLX and gtk/gdk/x11/gdkglcontext-egl.c is used for EGL.
Therefore, GTK3 does not support EGL-only x11 systems when drawing OpenGL ES. Am I right ~ ?
Thanks!
ebassi
(Emmanuele Bassi)
July 26, 2024, 3:17pm
34
On X11 systems, GTK3 only supports GLX to create a GL context, regardless of OpenGL or OpenGL ES; that is not going to change.
Thanks for the clear reply @ebassi @lb90
So GTK4 support EGL to create a GL context when using GDK_DEBUG=gl-egl
?
1 Like
system
(system)
Closed
August 28, 2024, 3:04pm
37
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.