I’m new to GTK & OpenCASCADE, but I’d say I’m a fairly competent programmer, although I haven’t done any C/C++ development in more than 10 years.
I’m trying to integrate OpenCASCADE with GTK4 usign gtkmm-4.0 bindings. I found this example demonstrating how to do it in GTK3:
github.com/gkv311/occt-samples-gtk and I hit a wall trying to figure out by myself.
There are other people not understanding some of what’s happening either:
- OCCT + GTK4 not working - Forum Open Cascade Technology
- c++ - Continuously render Gtk::GLArea in gtkmm - Stack Overflow
- How can a GtkGlArea’s size be 0 x 0 during the realize signal? [GTK4]
In the OpenCASCADE + GTK3 example there is some initialization done in the realize callback that fails in GTK4.
I started doing some tests, but I don’t understand the behavior.
https://github.com/razcore-rad/occt-gtk/tree/official-gtkin this branch I tested
Gtk::GLArea.get_height()using the official
gtkmm, because like the person from How can a GtkGlArea’ size be 0 x 0 […], I don’t understand why
size = 0 x 0.
https://github.com/razcore-rad/occt-gtk/tree/otherIn this branch I adapted the stackoverflow example for GTK3 & GTK4, plus made some bare-bones tests for checking out the behaviors between the two versions.
What I can see from the
stackoverflow_v4example is that
glewInit()gives an error in
on_my_realize()function, but even with the error the program still runs correctly - it makes the area blue.
The difference with
glewInit()doesn’t throw an error, but commenting it out also doesn’t throw any errors and the program behaves correctly - it makes the area blue.
Although it seems that GTK3 re-renders constantly while GTK4 only on resize or some event that triggers the re-render.
The reason I’m concerned about initializing the OpenGL context is because I have no idea what are the implications with OpenCASCADE if we don’t do it (using the OpenCASCADE API).
Please help us clarify what’s happening here, thanks!
As a side note (I haven’t tried this), but I imagine a solution for the
occt-samples-gtk demo is to move the code from the realize callback to the render callback, but then I’m not sure what is the purpose of the realize callback if we can’t use the OpenGL surface to set stuff like in this example, scaling for HDPI screens and such.
Doesn’t allow me to put more than 3 links.