GTK 4.14.4 GtkGLArea

A little while ago, I read this blog post and was excited to try GTK 4.14.4
https://blog.gtk.org/2024/01/28/new-renderers-for-gtk/

I have recently converted my computer to use debian unstable so that I can compile my applicataion with GTK 4.14.4. Everything goes fine until I run it - the OpenGL widget doesn’t start up as I hoped that it would.

I notice that gtk4-demo OpenGL “Gears” and “OpenGLArea” work, but “Shadertoy” gives me the message “Unable to create a GL context” - which is the same message that my application gives me.

I’d like some help to see why the OpenGLArea triangle app works, but Shadertoy does not - and if I can fix it.

Is it a known issue?

Is the antialiasing mentioned in the blog post going to (meant to) work in the GtkGLArea widget too? (that would be wonderful if so - currently the OpenGL labels can be hard to read (see attached)

Thanks,

Paul.

(p.s. I compile my application on my Mac laptop using homebrew which uses 4.14.something and it looks very sharp and lovely).

I’m on Fedora 40, which is currently shipping GTK 4.14.5. Running GSK_RENDERER=help gtk4-demo tells me that I have the new renderers available to me:

$ GSK_RENDERER=help gtk4-demo
Supported arguments for GSK_RENDERER environment variable:
  broadway - Use the Broadway specific renderer
   cairo - Use the Cairo fallback renderer
  opengl - Use the OpenGL renderer
      gl - Use the OpenGL renderer
     ngl - Use the new OpenGL renderer
  vulkan - Use the Vulkan renderer
    help - Print this help

Other arguments will cause a warning and be ignored.

If I run GSK_RENDERER=ngl gtk4-demo --run=shadertoy, I get a fairly performant OpenGL-rendered scene playing in the resulting application window. Launching the Gtk Inspector (Ctrl+Shift+d in the window once the demo is running) and going to the Global pane shows me that I am, indeed, taking advantage of the “GL (new)” renderer:

…If instead I run GSK_RENDERER=vulkan gtk4-demo --run=shadertoy, I get a horrifically laggy demo running that tries to freeze my entire session and leads to “application not responding” popups until I off it.

This is hardly surprising, as my GPU is a several-years-old, bargain-basement Nvidia card, running the nouveau drivers… I wouldn’t be surprised if any Vulkan support is entirely software-emulated:

My system is not built for Vulkan. I accept that.

But if I run GSK_RENDERER=gl gtk4-demo --run=shadertoy, I get a similarly-performant demo running to the ngl mode. I can’t immediately tell the difference between the two, at least for that demo, in terms of performance/quality. But they both work, on my system. If that answers your question at all?

…Actually, I take it back. Running them side-by-side (which my system was also able to do, though it wasn’t happy about it), I could definitely see the improved antialiasing of the ngl renderer. Most of the demo visuals are extremely “soft”/“fuzzy”, probably intentionally. (Hides a lot of rendering warts.) But the edge where that planet off in the distance meets the background sky, in that first demo, is a particularly good example of the improved antialiasing. It’s far less harsh and micro-jagged with the new renderer.

Sorry! That should be Ctrl+Shift+d. (Fixed.)

Oh, and BTW: On my system, the Inspector informs me that the default renderer chosen when I don’t set any GSK_RENDERER value in the process environment is the “GL (new)” renderer.

Hi Frank Dana,

Thanks for your reply.

I’m on Fedora 40

That interesting! Coot should be available there - although I’ve never seen it myself. Could I trouble you to install it and see how it looks/performs? (Calculate → Load Tutorial Model and Data, right-mouse to rotate, shift right-mouse to zoom, middle-mouse to recentre on an atom (it’s software for biochemists/chemists (and the most highly cited Free Software as far as I can tell (if that counts for anything))).

(I tried to install fedora on this machine, but the installer hung at the partioning stage)

OK, so I tried

GSK_RENDERER=help

and got the options that you did.

However, none of the options allowed shadertoy to run as intended


I am happy to hear that ngl gives you soft/fuzzy edges - that sounds like the antialiasing is working. However, for me, if I set GSK_RENDERER=ngl and run glarea I don’t see antialiasing:

Might it be a driver issue? It is not clear to me why the glarea works, but shadertoy does not.

Hmm. I did a package search for just that word, “coot”, and it came up with nothing. It’s possible it’s not in the official package collection.

It seems the author has some self-built binary packages, but hasn’t rolled one targeted for Fedora since some Fedora 26 builds back in 2018.

And the FAQ entries are hilariously out of date, providing vital information on the use of Coot with Fedora Core 2 or Fedora Core 3. (For the record, Fedora Core 3 was released in November 2004.)

Hmm. What kind of GPU does the machine have? Running eglinfo, glxinfo, and vainfo, and posting (partial) results, might be somewhat enlightening.

Oh, and Qt’s qtdiag also gives some generally-useful information on graphics capabilities as well.

Hmm. I did a package search for just that word, “coot”, and it came up with nothing

Oh no! Sorry. I misremembered. The build-it-3-3 script works out of the box, it’s not that Coot is now part of the OS on Fedora.

But running that is beyond the call of duty.

And the FAQ entries are hilariously out of date, providing vital information on the use of Coot with Fedora Core 2 or Fedora Core 3

Heh. Oh dear.

Hmm. What kind of GPU does the machine have?

I tried to include that in the screenshot - Nvidia GeForce RTX 2070 Super.

eglinfo gives

Lots of output… not sure what I am looking for. OpenGL seems to be there:

OpenGL core profile vendor: NVIDIA Corporation
OpenGL core profile renderer: NVIDIA GeForce RTX 2070 SUPER/PCIe/SSE2
OpenGL core profile version: 4.6.0 NVIDIA 535.183.06
OpenGL core profile shading language version: 4.60 NVIDIA
OpenGL core profile extensions:

glxinfo gives:

server glx vendor string: NVIDIA Corporation

OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: NVIDIA GeForce RTX 2070 SUPER/PCIe/SSE2
OpenGL core profile version string: 4.6.0 NVIDIA 535.183.06
OpenGL core profile shading language version string: 4.60 NVIDIA
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

vainfo:

That gives:

Trying display: wayland
Trying display: x11
libva info: VA-API version 1.22.0
libva error: vaGetDriverNames() failed with unknown libva error
vaInitialize failed with error code -1 (unknown libva error),exit

I googled the error. It doesn’t seem to be common.

I think that you have shown me that my problem is not to do with GTK 4 and is to do with my hardware and debian unstable. OK… Time to try something else.

Thank you.

I think my problem is related to this:

It is not clear to me from that if that is an Nvidia driver bug or a GTK4 bug.