Search code examples
openglgtkgtk3glx

GtkGLArea: GL_ARB_create_context_profile extension not found


I'm trying to get GTK+ 3.16's new GLArea widget to work. It is intended to provide built-in OpenGL support w/o relying on the outdated GtkGLExt/GtkGLArea projects. Since I'm not willing to update my working distribution to Gnome 3.16 just yet, I installed Fedora 22 Alpha on a virtual machine using Gnome Boxes.

Following ebassi's blog post I added a GLArea child to my window UI file:

<child>
    <object class="GtkGLArea" id="gl_drawing_area">
        <signal name="realize" handler="gl_init" swapped="yes"/>
        <signal name="unrealize" handler="gl_fini" swapped="yes"/>
        <signal name="render" handler="gl_draw" swapped="yes"/>
        <property name="visible">True</property>
        <property name="can_focus">False</property>
        <property name="hexpand">True</property>
        <property name="vexpand">True</property>
    </object>
</child>

and connected the signals. I should say that I'm using Vala for my UI code. The actual OpenGL code is intended to go into a C function that I would call from the gl_draw Vala method. For now, the three Vala functions just print their names.

Indeed, gl_init and gl_fini get called. But the GLArea widget displays this error message:

The GLX_ARB_create_context_profile extension needed to create core profiles is not available

I also tried to run ebassi's very own example program (GitHub). It does not even display the UI but outputs

glarea: Couldn't find current GLX or EGL context.

on the terminal right away.

However, running glxinfo tells me I got that extension installed:

name of display: :0
display: :0  screen: 0
direct rendering: Yes
server glx vendor string: SGI
server glx version string: 1.4
server glx extensions:
    GLX_ARB_multisample, GLX_EXT_import_context, GLX_EXT_texture_from_pixmap, 
    GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_MESA_copy_sub_buffer, 
    GLX_OML_swap_method, GLX_SGIS_multisample, GLX_SGIX_fbconfig, 
    GLX_SGIX_pbuffer, GLX_SGI_make_current_read
client glx vendor string: Mesa Project and SGI
client glx version string: 1.4
client glx extensions:
    GLX_ARB_create_context, GLX_ARB_create_context_profile, 
    GLX_ARB_create_context_robustness, GLX_ARB_fbconfig_float, 
    GLX_ARB_framebuffer_sRGB, GLX_ARB_get_proc_address, GLX_ARB_multisample, 
    GLX_EXT_buffer_age, GLX_EXT_create_context_es2_profile,
...

glxgears also runs without problems.

Moreover, I cloned the GNOME/gtkglarea repo in Github, compiled it myself and ran the examples without any problems. I understand this project developed the GLArea widget before it was officially included in GTK? (I was wrong about this.)


Solution

  • Running under virtualised environments is always fairly tricky.

    Even if you see the extension you may be unable to create a proper GLX context because of the requirement on the minimum version that GTK+ uses (i.e. 3.2); the llvmpipe software rasterizer in Mesa does not fully support OpenGL 3.2 because some of the required extensions are covered by patents. See bug 744407 for the details, as well as the plan going forward.

    As an aside: usually, being able to run glxgears is not an indication of being able to use OpenGL — except the very old, 1.x fixed pipeline API. Just like it's not an OpenGL benchmark, glxgears is not a good indicator of OpenGL availability, I'm afraid.