occQt | A simple OpenCASCADE Qt demo
kandi X-RAY | occQt Summary
kandi X-RAY | occQt Summary
occQt
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of occQt
occQt Key Features
occQt Examples and Code Snippets
Community Discussions
Trending Discussions on occQt
QUESTION
I'm trying to port the code from https://github.com/eryar/occQt to gtkmm, by creating a custom widget and overriding the Gtk::widget::on_realize() method like
...ANSWER
Answered 2021-Jul-29 at 16:53I haven't used GTK since university, so my experience is pretty basic here.
There are two basic approaches for embedding OpenGL-based viewer into GTK:
- Ask OCCT to create OpenGL context for a native window taken from a normal Widget or entire window.
- Wrap existing OpenGL context created by GUI library itself, e.g.
Gtk::GLArea
.
Your current code tries to follow the first approach used by conventional samples for Qt Widgets and MFC coming with OCCT. I guess it should be feasible, but implies some limitations and issues with mixing GTK widgets, as GTK will not be aware of OpenGL usage.
In contrast, Gtk::GLArea
looks like a "modern" way for embedding OpenGL renderer designed by GTK developers and expected to work transparently.
Therefore, I've tried implementing a Hello-World sample using Gtk::GLArea
(based on a development snapshot of OCCT 7.6.0dev):
https://github.com/gkv311/occt-samples-gtk
I don't bring the whole code of the sample here, as it is quite large in size.
Putting OCCT Viewer into Gtk::GLArea
includes some tricky parts like:
- Wrapping native Window into
Aspect_Window
(it could be alsoXw_Window
like in your sample, more generalAspect_NeutralWindow
or another subclass). - Wrapping OpenGL context created by
Gtk::GLArea
intoAspect_RenderingContext
/OpenGl_Context
. - Wrapping offscreen buffer (FBO) used by
Gtk::GLArea
for rendering content intoOpenGl_FrameBuffer
. - Putting all viewer redraws into dedicated callback for
Gtk::GLArea::signal_render()
. - Redirecting user input to viewer (with help of
AIS_ViewController
).
It is important to note, that GTK may be run in different context:
- X11 server - X Window is created and
GLX
is used for OpenGL.
This is default OCCT configuration for Linux; - Wayland - native window is not X Window and
EGL
is used for OpenGL context.
OCCT does supportEGL
but as a dedicated configuration as alternative toGLX
, while GTK handles this in runtime somehow. In addition, OCCT does not (yet) provide any wrapper for a Wayland native window, though it might be not critical for using. - GTK also has an option to use OpenGL ES instead of OpenGL.
Initially I expected Gtk::GLArea
to work natively, but instead a very basic sample (without OCCT viewer) displays artifacts to me (widgets randomly blacked) on Xubuntu 18.04, though it works as expected on Ubuntu 21.04 (within Xorg session). I don't know if it is a bug fixed in GTK implementation, or there is something that should be fixed in a sample to workaround problem on older Linux.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install occQt
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page