Qt-Advanced-Docking-System icon indicating copy to clipboard operation
Qt-Advanced-Docking-System copied to clipboard

Add open gl example and fix #717

Open zyrkiel opened this issue 9 months ago • 12 comments

Fix issue #717

Add an OpenGL example to check/test how ADS handles widgets that include OpenGL rendering.

In order to fix weird behavior and crashes, some winId() have been added to the code. It forces some widgets/windows to be managed as native widgets instead of aliens (non-native). Some doc about native and aliens: https://doc.qt.io/qt-6/qwidget.html#native-widgets-vs-alien-widgets

These changes can theoreticaly induced a drop of performances, but I didn'tt noticed them. I have observed a speedup of the UI launch and reaction on both Ubuntu 24.04 and Windows 11.

These changes should not affect how the lib is working under Windows, the demo example has been run under Windows and Ubuntu and all seems to work well.

On Ubuntu, the handling of OpenGL is now working thanks to these modifications.

The OpenGL example has been developped with components from the following Qt examples:

  • hellogl2
  • hellogles3
  • qquickwidgetversuswindow_opengl

The example has been tested on Ubuntu 24.04, Windows 11 with QtCreator and cmake.

Some weird behaviors are still present on Ubuntu (docking a QOpenGLWiidget/QQuickWidget floating window in a QOpenGLWindow/QQuickView container floating window seems to destroy the contained window) but globaly it's working fine.

It has taking quite a while to achieve this result. I hope this will suit you.

Please give it a try.

zyrkiel avatar Mar 20 '25 13:03 zyrkiel

Thank you for your pull request. Do you really thing this is necessary to make the widgets to native widgets. In our application we use the OpenGL based Coin3D library without any problems in the ADS docking system (see the Robot visualization on the front page). Also other user seem to use ADS to display 3D content without any problems so I'm not really convinced from this change.

githubuser0xFFFF avatar Mar 20 '25 19:03 githubuser0xFFFF

Yes the fix seems mandatory to use OpenGL on Ubuntu. You have a very good example of a crash in the issue #717 description. It should also fix #281 you mentioned. A lot of other undesired behavior happen too. Please test the 2 first commits of the OpenGL example on Ubuntu (without the fix) to understand what could goes wrong.

If you have better fixes to make OpenGL widgets working on Ubuntu, I would be pleased.

zyrkiel avatar Mar 21 '25 08:03 zyrkiel

Thank you for the pull request. Because the change might have negative side effects on other applications, I would like to ask you to add a new configuration flag, such as USE_NATIVE_WINDOWs or something similar that is disabled by default. Then only create native Widgets, if it is enabled.

Would this be o.k. fir you?

githubuser0xFFFF avatar May 03 '25 07:05 githubuser0xFFFF

Yeah, that suits me. I will do the changes

zyrkiel avatar May 05 '25 10:05 zyrkiel

Great. I really appreciate your contribution.

githubuser0xFFFF avatar May 05 '25 11:05 githubuser0xFFFF

I have updated my PR, could you have a look and see if the modifications suits you?

However, I am having a bad time trying to make things work on your CI which runs with Qt 5. Is it possible to use Qt 6? Or could I just skip the OpenGL example if Qt6 is not found?

zyrkiel avatar May 07 '25 15:05 zyrkiel

@zyrkiel Thank you for the changes. I noticed, that you used compile time configuration via the define USE_NATIVE_WINDOWS. My idea was to provide an addtional config flag USE_NATIVE_WINDOWS for the eConfigFlag and then do a runtime check via CDockManager::testConfigFlag(CDockManager::USE_NATIVE_WINDOWS for this flag. For Linux the package managers will provide only one library, so I do not now if they like the idea of compiling different libraries.

What do you think?

githubuser0xFFFF avatar May 08 '25 19:05 githubuser0xFFFF

Your solution seems better and easier to use than my compile time configuration. I am doing the changes

zyrkiel avatar May 09 '25 14:05 zyrkiel

@zyrkiel This is great. Thank you very much.

githubuser0xFFFF avatar May 10 '25 04:05 githubuser0xFFFF

How do you want to proceed to make the CI work?

zyrkiel avatar May 10 '25 12:05 zyrkiel

The CI for Linux only uses Qt6. Do you see issues for Qt5 on Windows?

githubuser0xFFFF avatar May 10 '25 15:05 githubuser0xFFFF

It seems that QOpenGLWidget has been moved to Qt OpenGLWidgets package in Qt6 and ShaderTools package does not exist either in Qt 5. But I need them since I have developped the OpenGL example with Qt examples that uses them.

It seems to be a cmake issue. Should I disable the OpenGL example by default when building with cmake? And let the user build it if BUILD_OPENGL_EXAMPLE is given to cmake configuration?

zyrkiel avatar May 12 '25 07:05 zyrkiel