projectM-visualizer / frontend-qt

:bangbang: CURRENTLY BROKEN :bangbang: - Will be fixed some time after the libprojectM 4.0 release! Help is highly appreciated. Qt-based standalone frontend to projectM. Currently supports Linux with PulseAudio or JACK audio backends.
GNU Lesser General Public License v2.1
12 stars 5 forks source link

Rendering into QOpenGLWidget produces broken output #1

Open kblaschke opened 3 years ago

kblaschke commented 3 years ago

Describe the bug After changing the Qt frontend to use QOpenGLWidget instead of QGLWidget, rendering output is broken.

At some point in the rendering queue, OpenGL resources become corrupted, e.g. vertex buffers have invalid or wrong contents (too few vertices). This subsequentially breaks the vertex shader and causes following commands to also fail, rendering garbage.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context The main difference between rendering into an SDL2 OpenGL or QGLWidget context is that the new QOpenGLWidget expects GL commands to render into a FBO instead of directly into the current GL context. ProjectM doesn't really care about OpenGL contexts or FBO usage, which might be the root cause of this issue.

RenderDoc captures of both the Qt and SDL frontends, using the same preset, can be found here.

kblaschke commented 3 years ago

Commit 237fe34 fixes the issue for now by providing a clean, native window projectM can render on. It's not ideal since hiding the mouse cursor is now a bit wonky (QWindow has different mouse events than QWidget), but at least the presets render correctly.

If someone has more experience with Qt's QOpenGLWidget specifics and knows how to make projectM render correctly into it, help is very much appreciated!

Be-ing commented 3 years ago

I don't know how to help with this specific issue, but moving to QOpenGLWidget is definitely the way to go. QGLWidget has been removed in Qt6 (which requires rewriting Mixxx's entire GUI in QML because rendering the old QWidgets GUI revolves around QGLWidget APIs which have no equivalent in QOpenGLWidget).

kblaschke commented 3 years ago

Ideally projectM should create its own internal context and render to a framebuffer object, which the integrating application can then copy to the buffer being displayed on screen, in this case the QOpenGLWidget's surface. Currently projectM has no knowledge of FBOs or contexts at all, it just renders to any context that's been made current when the render method is called each frame.