tcobbs / ldview

Real-time 3D viewer for displaying LDraw models
https://tcobbs.github.io/ldview/
GNU General Public License v2.0
87 stars 17 forks source link

Wayland display issue on Qt6 #84

Open pbartfai opened 4 months ago

pbartfai commented 4 months ago

Describe the bug Backing store is not working on Qt6 using QOpenGLWidget

To Reproduce to build run the following command: qmake-qt6.sh -spec linux-g++-64 ; make clean all

run the following command ./LDView -platform wayland ../m6459.ldr

Expected behavior Clear background is expected

Screenshots

image

Platform (please complete the following information):

Additional context Same issue ont Qt5 if option QOPENGLWIDGET is enabled. Without option QOPENGLWIDGET blank window is displayed on Wayland.

pbartfai commented 4 months ago

Changing the memory usage to high or medium will cause total mess. With low memory usage, the display is better, but not perfect. Problem experienced with QOpenGLWidget on both Wayland and xcb. image

pbartfai commented 4 months ago

When rotating the model the earlier phases are not cleared, background is not refreshed: image image

pbartfai commented 4 months ago

Problem could be recreated with Qt6 example openglwindow (https://doc.qt.io/qt-6/qtopengl-openglwindow-example.html) Similar issues on the following Qt5 examples:

tcobbs commented 4 months ago

The ghosting problem sounds like a problem with double buffering, but it could also be a problem with clearing the color buffers in the back buffer.

The memory usage problems are probably related to display lists, since changing the memory usage setting mainly changes what gets stored in display lists. (The high memory usage setting also flattens the conditional line geometry to the top level to allow for multithreaded conditional processing.)

Given that you see the same problems in the Qt examples, I would say that either Qt itself is broken, or that Wayland is broken. If I had to guess, they never bothered to test OpenGL 1.x functionality.

Unfortunately, I can't think of anything to do to fix LDView. You may be able to fiddle around with the QOpenGLWidget's buffering settings to fix the ghosting, and you may not (since it certainly appears to be Qt and/or Wayland that is broken, not LDView).

For the memory usage problems, I feel that the same applies, but you could test my supposition about display lists by modifying the code to never set the display list flags to true when running in Qt6. I think that the best way to do this is to just use #ifdefs in TREMainModel.h to override setCompilePartsFlag and setCompileAllFlag to not do anything. (The flags default to false, so preventing them from being set to true would disable display list usage.) If this works, go ahead and rearrange the code so that those two functions are next to each other so you only need one #ifdef/#else pair.

If you can't figure out how to fix the ghosting by tweaking the QOpenGLWidget's settings, try calling setSlowClear(true) on the LDrawModelViewer instance.

Regarding snapshot saves, I don't even know where to begin. Once again, I strongly suspect that the problem is buggy Qt and/or Wayland, and I don't have any real hope of figuring out a fix.