Downgraded the OpenGL context version to 2.1. Qt's QOpenGLPaintDevice is

not compatible with OpenGL versions >= 3.0. NVIDIA does not care, but
unfortunately AMD does.
Also tweaked some other qt & opengl settings for more pleasant visuals.
This commit is contained in:
2016-09-22 00:16:35 +02:00
parent 439a46ec82
commit 8e815b0ce4
+16 -4
View File
@@ -43,9 +43,15 @@ namespace advsettings {
} }
QSurfaceFormat format; QSurfaceFormat format;
format.setMajorVersion( 4 ); // Qt's QOpenGLPaintDevice is not compatible with OpenGL versions >= 3.0
format.setMinorVersion( 1 ); // NVIDIA does not care, but unfortunately AMD does
format.setProfile( QSurfaceFormat::CompatibilityProfile ); // Are subtle changes to the semantics of OpenGL functions actually covered by the compatibility profile,
// and this is an AMD bug?
format.setVersion(2, 1);
//format.setProfile( QSurfaceFormat::CompatibilityProfile );
format.setDepthBufferSize(16);
format.setStencilBufferSize(8);
format.setSamples(16);
m_pOpenGLContext.reset(new QOpenGLContext()); m_pOpenGLContext.reset(new QOpenGLContext());
m_pOpenGLContext->setFormat(format); m_pOpenGLContext->setFormat(format);
@@ -55,6 +61,7 @@ namespace advsettings {
// create an offscreen surface to attach the context and FBO to // create an offscreen surface to attach the context and FBO to
m_pOffscreenSurface.reset(new QOffscreenSurface()); m_pOffscreenSurface.reset(new QOffscreenSurface());
m_pOffscreenSurface->setFormat(m_pOpenGLContext->format());
m_pOffscreenSurface->create(); m_pOffscreenSurface->create();
m_pOpenGLContext->makeCurrent(m_pOffscreenSurface.get()); m_pOpenGLContext->makeCurrent(m_pOffscreenSurface.get());
@@ -95,7 +102,11 @@ void OverlayController::SetWidget(OverlayWidget *pWidget, const std::string& nam
m_pPumpEventsTimer->setInterval(20); m_pPumpEventsTimer->setInterval(20);
m_pPumpEventsTimer->start(); m_pPumpEventsTimer->start();
m_pFbo.reset(new QOpenGLFramebufferObject(pWidget->width(), pWidget->height(), GL_TEXTURE_2D)); QOpenGLFramebufferObjectFormat fboFormat;
fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
fboFormat.setTextureTarget(GL_TEXTURE_2D);
m_pFbo.reset(new QOpenGLFramebufferObject(pWidget->width(), pWidget->height(), fboFormat));
vr::HmdVector2_t vecWindowSize = { vr::HmdVector2_t vecWindowSize = {
(float)pWidget->width(), (float)pWidget->width(),
@@ -122,6 +133,7 @@ void OverlayController::OnSceneChanged( const QList<QRectF>& ) {
QOpenGLPaintDevice device(m_pFbo->size()); QOpenGLPaintDevice device(m_pFbo->size());
QPainter painter(&device); QPainter painter(&device);
painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
m_pScene->render(&painter); m_pScene->render(&painter);