33#include " OcctQtTools.h"
44
55#include < OpenGl_Caps.hxx>
6+ #include < OSD_Environment.hxx>
67#include < Standard_Version.hxx>
78
9+ #include < QCoreApplication>
10+
811// ================================================================
912// Function : qtColorToOcct
1013// ================================================================
@@ -22,6 +25,52 @@ QColor OcctQtTools::qtColorFromOcct(const Quantity_Color& theColor)
2225 return QColor ((int )Round (anRgb.r () * 255.0 ), (int )Round (anRgb.g () * 255.0 ), (int )Round (anRgb.b () * 255.0 ));
2326}
2427
28+ // ================================================================
29+ // Function : qtGlPlatformSetup
30+ // ================================================================
31+ void OcctQtTools::qtGlPlatformSetup ()
32+ {
33+ #if defined(_WIN32)
34+ // never use ANGLE on Windows, since OCCT 3D Viewer does not expect this;
35+ // use Qt::AA_UseOpenGLES for embedded systems
36+ QCoreApplication::setAttribute (Qt::AA_UseDesktopOpenGL);
37+ #elif defined(__APPLE__)
38+ //
39+ #else
40+ // Qt6 tries to use Wayland platform by default, which is incompatible with OCCT depending on Xlib;
41+ // Force 'xcb' platform plugin (alternatively, could be passed QApplication as '-platfom xcb' argument).
42+ OSD_Environment aQpaPlat (" QT_QPA_PLATFORM" );
43+ if (aQpaPlat.Value ().IsEmpty ())
44+ {
45+ aQpaPlat.SetValue (" xcb" );
46+ aQpaPlat.Build ();
47+ }
48+ #endif
49+
50+ /* #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
51+ // workaround for some bugs in Qt5
52+ OSD_Environment aQGlyph("QT_ENABLE_GLYPH_CACHE_WORKAROUND");
53+ if (aQGlyph.Value().IsEmpty())
54+ {
55+ aQGlyph.SetValue("1");
56+ aQGlyph.Build();
57+ }
58+ #endif*/
59+
60+ // global OpenGL setup managed by Qt
61+ const QSurfaceFormat aGlFormat = OcctQtTools::qtGlSurfaceFormat ();
62+ QSurfaceFormat::setDefaultFormat (aGlFormat);
63+
64+ // ask Qt managing rendering from GUI thread instead of QSGRenderThread
65+ // for QtQuick applications
66+ /* OSD_Environment aQsgLoop("QSG_RENDER_LOOP");
67+ if (aQsgLoop.Value().IsEmpty())
68+ {
69+ aQsgLoop.SetValue("basic");
70+ aQsgLoop.Build();
71+ }*/
72+ }
73+
2574// ================================================================
2675// Function : qtGlSurfaceFormat
2776// ================================================================
0 commit comments