-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenGL viewport assertion when trying to embed GLWidget in parent window #184
Comments
What the "standalone map viewer" means is that you also get the map instance with it (so you just add the widget and get everything). You can certainly put it as child in the UI. Actually the example that we use even supports docked windows. How do you run your Windows app? You need to force OpenGL and not use DirectX (which I think is the default in Qt 6). |
Thank you for the quick response! I believe I know the reason for this discrepancy: the assertion occurs only in Debug mode. I started with a new, empty Qt Widgets template project in Visual Studio. Adding the following code to the constructor is enough to trigger the assertion:
The example code from the source added to the empty Qt project runs fine in Release mode but asserts in Debug mode when the window is resized. The assertion occurs here:
Note that when attempting to run the example created using CMake/Ninja, I got the following error: "This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem" after copying over the library and the Qt DLLs, so I haven't been actually able to test the widget example source code in this exact setup. In my initial tests, everything worked fine in Debug mode when launched in a standalone window. However, the issue arose when I embedded it as a child window. Please let me know and I can send over this minimal repro. |
I think I've identified the root cause of the viewport assertion. It's happening due to a DPI scaling rounding mismatch between Qt and OpenGL. In my case with a 150% DPI scaling Qt rounds up the scaled dimensions while OpenGL truncates them: // Example from my debug logs:
This 1-pixel difference triggers the assertion in debug builds. Something like this might help:
|
I'm trying to embed QMapLibre::GLWidget as a child widget in my Qt application's main window, but running into OpenGL viewport assertions.
The assertion happens in
mbgl::gl::RendererBackend::assumeViewport()
when the widget is being shown as part of the parent window's widget hierarchy. I noticed in the docs that GLWidget is described as "intended as a standalone map viewer", but I wanted to confirm if this is a known limitation. Are there any workarounds to properly embed it in a parent window? Is separate window approach the best solution? Any guidance would be appreciated.Environment:
Qt 6.8
Windows 10
The text was updated successfully, but these errors were encountered: