Rust GTK-RS and GLArea

Hello all,

I had come here today for some insight. I had recently stumbled across the GTK API for Rust, named gtk-rs. This api is absolutely amazing, and is capable of pulling off the GTK we know and love within the Rust environment. I do not have a very large background with GTK, but had always been aware of it. I am attempting to use a GLArea element to render a simple quad to the screen, and there are a ton of apis to do opengl.

However, I had taken a look at the gtk-rs/GLArea documentation and the examples of usage appears to be in C, which does not really help me unfortunately. I am trying my hardest to find some concrete information on rendering OpenGL in the GLArea, but am unable to find anything. Any ideas on doing this? I will include a snippet of what I have currently.

I appreciate all of the help everyone.

Just like in the C example code, the GL context is current in the render signal handler and you can directly call GL functions.

You can use the gl crate for directly calling GL functions from Rust.

I appreciate the reply! I’m looking at the documentation of the GL API, however loading the function pointers seems to be where I’m stuck. It looks like I’m unable to find the function that gets the process address to link the gl crate.

I don’t know how that’s supposed to be done with GTK. GStreamer provides its own specific functions for loading GL functions pointers for this very reason because it’s non-trivial to load the correct ones. The GTK C examples seem to just assume that the functions are linked in normally and are just available to be called.

Maybe epoxy would be an option here.

As GTK has a hard dependency on libepoxy, yes: it expects the GL functions to be available already.

Nothing really prevents you from dlopen()‘ing libGL and populating the symbols vtable/trampolines on your own, though. As far as I know, for instance, pyopengl works fine with GTK and the GLArea widget.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.