Hi,
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-gtk
in this branch I testedGtk::GLArea.get_width()
andGtk::GLArea.get_height()
using the officialGLArea
example fromgtkmm
, because like the person from How can a GtkGlArea’ size be 0 x 0 […], I don’t understand whysize = 0 x 0
. -
https://github.com/razcore-rad/occt-gtk/tree/other
In 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_v4
example is thatglewInit()
gives an error inon_my_realize()
function, but even with the error the program still runs correctly - it makes the area blue.The difference with
stackoverflow_v3
is thatglewInit()
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.
P.S.
Doesn’t allow me to put more than 3 links.