Gui/Application, QuarterWidget: request OpenGL compatibility profile (#23768)
On Wayland with Qt, the default OpenGL context often ends up being OpenGL ES. ES is a stricter API based on the "core" profile and lacks many legacy functions (e.g. glEnd). FreeCAD relies on some of these functions, which work under Mesa’s permissive stack but fail outright with NVIDIA’s proprietary drivers, resulting in a blank 3D view. Fix this by explicitly requesting a desktop OpenGL compatibility profile both before QApplication creation and in QuarterWidget. This ensures the presence of the legacy entry points required by Coin/SoQt. (NB: both requests appear to be necessary; a single change was not sufficient in testing.)
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include <QScreen>
|
||||
#include <QStatusBar>
|
||||
#include <QStyle>
|
||||
#include <QSurfaceFormat>
|
||||
#include <QTextStream>
|
||||
#include <QTimer>
|
||||
#include <QWindow>
|
||||
@@ -2383,6 +2384,12 @@ void Application::runApplication()
|
||||
{
|
||||
StartupProcess::setupApplication();
|
||||
|
||||
QSurfaceFormat fmt;
|
||||
fmt.setRenderableType(QSurfaceFormat::OpenGL);
|
||||
fmt.setProfile(QSurfaceFormat::CompatibilityProfile);
|
||||
fmt.setOption(QSurfaceFormat::DeprecatedFunctions, true);
|
||||
QSurfaceFormat::setDefaultFormat(fmt);
|
||||
|
||||
// A new QApplication
|
||||
Base::Console().log("Init: Creating Gui::Application and QApplication\n");
|
||||
|
||||
|
||||
@@ -160,6 +160,15 @@ public:
|
||||
//surfaceFormat.setMajorVersion(3);
|
||||
//surfaceFormat.setMinorVersion(2);
|
||||
//surfaceFormat.setProfile(QSurfaceFormat::CoreProfile);
|
||||
|
||||
// On Wayland, we typically get a core profile unless we explicitly
|
||||
// request a compatibility profile. On llvmpipe, this still seems to
|
||||
// "just work" even if out of spec; on proprietary Nvidia drivers, it
|
||||
// does not.
|
||||
surfaceFormat.setRenderableType(QSurfaceFormat::OpenGL);
|
||||
surfaceFormat.setProfile(QSurfaceFormat::CompatibilityProfile);
|
||||
surfaceFormat.setOption(QSurfaceFormat::DeprecatedFunctions, true);
|
||||
|
||||
#if defined (_DEBUG) && 0
|
||||
surfaceFormat.setOption(QSurfaceFormat::DebugContext);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user