OpenGL Context Creation Error on Apalis i.MX8QM SOM with Yocto Build

Hi team,

I have a Apalis i.MX8QM SOM with ixora v1.3 carrier board. I created a Yocto build linux with the
tdx-reference-multimedia-image.

Packages i have additionally added in the local.conf

CORE_IMAGE_EXTRA_INSTALL += "curl"
CORE_IMAGE_EXTRA_INSTALL += "git"
CORE_IMAGE_EXTRA_INSTALL += "bash"
CORE_IMAGE_EXTRA_INSTALL += "python3-pip"
CORE_IMAGE_EXTRA_INSTALL += "rsync"
CORE_IMAGE_EXTRA_INSTALL += "glibc-utils"
CORE_IMAGE_EXTRA_INSTALL += "zip"
CORE_IMAGE_EXTRA_INSTALL += "make"
CORE_IMAGE_EXTRA_INSTALL += "cmake"
CORE_IMAGE_EXTRA_INSTALL += "gcc"
CORE_IMAGE_EXTRA_INSTALL += "file"
CORE_IMAGE_EXTRA_INSTALL += "ninja"
CORE_IMAGE_EXTRA_INSTALL += "clang"
CORE_IMAGE_EXTRA_INSTALL += "pkgconfig"
CORE_IMAGE_EXTRA_INSTALL += "gtk+3-dev"
CORE_IMAGE_EXTRA_INSTALL += "gtk+3"
CORE_IMAGE_EXTRA_INSTALL += "pango"
CORE_IMAGE_EXTRA_INSTALL += "autoconf automake libtool"
CORE_IMAGE_EXTRA_INSTALL += "python3-pip"
CORE_IMAGE_EXTRA_INSTALL += "meson"
CORE_IMAGE_EXTRA_INSTALL += "glib-2.0"
CORE_IMAGE_EXTRA_INSTALL += "bison"
CORE_IMAGE_EXTRA_INSTALL += "flex"
CORE_IMAGE_EXTRA_INSTALL += "packagegroup-core-buildessential"
CORE_IMAGE_EXTRA_INSTALL += "libgpiod libgpiod-tools libgpiod-dev"
CORE_IMAGE_EXTRA_INSTALL += "wayland-protocols"
CORE_IMAGE_EXTRA_INSTALL += "libclc-imx"
CORE_IMAGE_EXTRA_INSTALL += "libclc-imx-dev"
CORE_IMAGE_EXTRA_INSTALL += "libgles1-imx"
CORE_IMAGE_EXTRA_INSTALL += "libgles1-imx-dev"
CORE_IMAGE_EXTRA_INSTALL += "libgles2-imx"
CORE_IMAGE_EXTRA_INSTALL += "libgles2-imx-dev"
CORE_IMAGE_EXTRA_INSTALL += "libgles3-imx-dev"
CORE_IMAGE_EXTRA_INSTALL += "libglslc-imx"
CORE_IMAGE_EXTRA_INSTALL += "libopencl-imx"
CORE_IMAGE_EXTRA_INSTALL += "libegl-imx"
CORE_IMAGE_EXTRA_INSTALL += "libegl-imx-dev"
CORE_IMAGE_EXTRA_INSTALL += "libgal-imx"
CORE_IMAGE_EXTRA_INSTALL += "libgal-imx-dev"
CORE_IMAGE_EXTRA_INSTALL += "libvsc-imx"
CORE_IMAGE_EXTRA_INSTALL += "libgbm-imx"
CORE_IMAGE_EXTRA_INSTALL += "libgbm-imx-dev"
CORE_IMAGE_EXTRA_INSTALL += "libvulkan-imx"
CORE_IMAGE_EXTRA_INSTALL += "libopenvx-imx"
CORE_IMAGE_EXTRA_INSTALL += "libopenvx-imx-dev"
CORE_IMAGE_EXTRA_INSTALL += "libnn-imx"
CORE_IMAGE_EXTRA_INSTALL += "imx-gpu-viv-tools"
CORE_IMAGE_EXTRA_INSTALL += "apitrace"
CORE_IMAGE_EXTRA_INSTALL += "cmake"
CORE_IMAGE_EXTRA_INSTALL += "compiler-rt-dev"
CORE_IMAGE_EXTRA_INSTALL += "libcxx-dev"
CORE_IMAGE_EXTRA_INSTALL += "ca-certificates"
CORE_IMAGE_EXTRA_INSTALL += "atk"
CORE_IMAGE_EXTRA_INSTALL += "cairo-dev"
CORE_IMAGE_EXTRA_INSTALL += "fontconfig"
CORE_IMAGE_EXTRA_INSTALL += "libdrm-dev"
CORE_IMAGE_EXTRA_INSTALL += "libxkbcommon"
CORE_IMAGE_EXTRA_INSTALL += "perl"
CORE_IMAGE_EXTRA_INSTALL += "perl-modules"
CORE_IMAGE_EXTRA_INSTALL += "unzip"
CORE_IMAGE_EXTRA_INSTALL += "gtk4-dev"
CORE_IMAGE_EXTRA_INSTALL += "upower-dev"
CORE_IMAGE_EXTRA_INSTALL += "xdg-user-dirs"
CORE_IMAGE_EXTRA_INSTALL += "weston"
CORE_IMAGE_EXTRA_INSTALL += "weston-launch"
CORE_IMAGE_EXTRA_INSTALL += "weston-init"
CORE_IMAGE_EXTRA_INSTALL += "wayland-utils"

DISTRO_FEATURES += "systemd wayland vulkan opengl opengles2 egl gles gles2"

When i ran the below below program, i got the error related to opengl. But there is a blank white screen window is showing in the display with a text ‘No GL implementation is available

Program:

root@apalis-imx8-07307228:~/opengl# cat gtk_gl_test.c 
#include <gtk/gtk.h>
#include <epoxy/gl.h>
#include <epoxy/egl.h>

static void on_realize(GtkGLArea *area) {
    gtk_gl_area_make_current(area);
    if (gtk_gl_area_get_error(area) != NULL) {
        printf("Failed to create GL context\n");
        return;
    }
    printf("GL Version: %s\n", glGetString(GL_VERSION));
}

static void activate(GtkApplication *app, gpointer user_data) {
    GtkWidget *window = gtk_application_window_new(app);
    GtkWidget *gl_area = gtk_gl_area_new();
    
    gtk_gl_area_set_use_es(GTK_GL_AREA(gl_area), TRUE);  // Use OpenGL ES
    gtk_gl_area_set_required_version(GTK_GL_AREA(gl_area), 3, 2);  // Require OpenGL ES 3.2
    
    g_signal_connect(gl_area, "realize", G_CALLBACK(on_realize), NULL);
    gtk_container_add(GTK_CONTAINER(window), gl_area);
    gtk_widget_show_all(window);
}

int 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);
    int status = g_application_run(G_APPLICATION(app), argc, argv);
    g_object_unref(app);
    return status;
}

Error:

root@apalis-imx8-07307228:~/opengl# gcc -o gtk_gl_test gtk_gl_test.c $(pkg-config --cflags --libs gtk+-3.0 epoxy)
root@apalis-imx8-07307228:~/opengl# ./gtk_gl_test 
Failed to create GL context
^C
root@apalis-imx8-07307228:~/opengl# 

The ultimate goal is runnig flutter application. When i ran the flutter application, same issue is happening.

Any help will be appreciated.

Regards,
Hareendran

Hi, I’m the Toradex AI Assistant. I’m in early beta, and I would appreciate your feedback.
The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


It looks like you’re encountering an issue with OpenGL context creation on your Apalis i.MX8QM SOM with the Ixora v1.3 carrier board. Here are a few steps and suggestions to help you troubleshoot and resolve this issue:

  1. Verify GPU Drivers and Libraries:
    Ensure that the necessary GPU drivers and libraries are correctly installed and configured. You have included many relevant packages in your local.conf, but double-check that they are correctly built and included in your image.

  2. Check Weston Configuration:
    Since you are using Weston, make sure that it is properly configured to use the GPU. You can check the Weston logs for any errors related to GPU initialization. The logs can be found in /var/log/weston.log.

  3. Verify OpenGL ES Support:
    Ensure that OpenGL ES support is enabled and functioning. You can use the glxinfo or es2_info command to check the OpenGL ES version and capabilities. If these tools are not installed, you can add them to your image.

  4. Test with a Simple OpenGL ES Application:
    Before running your GTK application, test with a simple OpenGL ES application to verify that the GPU and drivers are working correctly. You can use a basic OpenGL ES example to do this.

  5. Check for Errors in Your Code:
    Ensure that your code is correctly setting up the OpenGL ES context. The error message “Failed to create GL context” suggests that the context creation is failing. Double-check the gtk_gl_area_set_use_es and gtk_gl_area_set_required_version calls to ensure they are correct.

  6. Update and Rebuild Your Image:
    Sometimes, updating the Yocto layers and rebuilding the image can resolve issues related to missing or outdated packages. Make sure you have the latest meta-layers and rebuild your image.

  7. Consult Toradex Resources:
    Refer to the Toradex documentation and community forums for any specific configurations or known issues related to OpenGL ES on the Apalis i.MX8QM. The Toradex support team can also provide valuable insights.

Here is a simplified example to test OpenGL ES context creation:

#include <GLES2/gl2.h>
#include <EGL/egl.h>
#include <stdio.h>

int main() {
    EGLDisplay display;
    EGLConfig config;
    EGLContext context;
    EGLSurface surface;
    EGLint num_config;
    EGL