mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Codify qt qml version in one header
This commit is contained in:
parent
d79d66c34e
commit
be489e8728
4 changed files with 11 additions and 4 deletions
|
@ -12,11 +12,12 @@ const QSurfaceFormat& getDefaultOpenGLSurfaceFormat() {
|
|||
// Qt Quick may need a depth and stencil buffer. Always make sure these are available.
|
||||
format.setDepthBufferSize(DEFAULT_GL_DEPTH_BUFFER_BITS);
|
||||
format.setStencilBufferSize(DEFAULT_GL_STENCIL_BUFFER_BITS);
|
||||
format.setVersion(4, 5);
|
||||
setGLFormatVersion(format);
|
||||
#ifdef DEBUG
|
||||
format.setOption(QSurfaceFormat::DebugContext);
|
||||
#endif
|
||||
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile);
|
||||
QSurfaceFormat::setDefaultFormat(format);
|
||||
});
|
||||
return format;
|
||||
}
|
||||
|
@ -27,11 +28,12 @@ const QGLFormat& getDefaultGLFormat() {
|
|||
static QGLFormat glFormat;
|
||||
static std::once_flag once;
|
||||
std::call_once(once, [] {
|
||||
glFormat.setVersion(4, 5);
|
||||
setGLFormatVersion(glFormat);
|
||||
glFormat.setProfile(QGLFormat::CoreProfile); // Requires >=Qt-4.8.0
|
||||
glFormat.setSampleBuffers(false);
|
||||
glFormat.setDepth(false);
|
||||
glFormat.setStencil(false);
|
||||
QGLFormat::setDefaultFormat(glFormat);
|
||||
});
|
||||
return glFormat;
|
||||
}
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
class QSurfaceFormat;
|
||||
class QGLFormat;
|
||||
|
||||
template<class F>
|
||||
void setGLFormatVersion(F& format, int major = 4, int minor = 5) { format.setVersion(major, minor); }
|
||||
|
||||
const QSurfaceFormat& getDefaultOpenGLSurfaceFormat();
|
||||
const QGLFormat& getDefaultGLFormat();
|
||||
#endif
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include <gl/QOpenGLContextWrapper.h>
|
||||
#include <gl/QOpenGLDebugLoggerWrapper.h>
|
||||
#include <gl/GLHelpers.h>
|
||||
|
||||
#include <GLMHelpers.h>
|
||||
#include <PathUtils.h>
|
||||
|
@ -141,7 +142,7 @@ public:
|
|||
// Qt Quick may need a depth and stencil buffer. Always make sure these are available.
|
||||
format.setDepthBufferSize(16);
|
||||
format.setStencilBufferSize(8);
|
||||
format.setVersion(4, 3);
|
||||
setGLFormatVersion(format);
|
||||
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile);
|
||||
format.setOption(QSurfaceFormat::DebugContext);
|
||||
format.setSwapInterval(0);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include <gl/QOpenGLContextWrapper.h>
|
||||
#include <gl/QOpenGLDebugLoggerWrapper.h>
|
||||
#include <gl/GLHelpers.h>
|
||||
|
||||
#include <QDir>
|
||||
#include <QElapsedTimer>
|
||||
|
@ -98,7 +99,7 @@ public:
|
|||
// Qt Quick may need a depth and stencil buffer. Always make sure these are available.
|
||||
format.setDepthBufferSize(16);
|
||||
format.setStencilBufferSize(8);
|
||||
format.setVersion(4, 1);
|
||||
setGLFormatVersion(format);
|
||||
format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile);
|
||||
format.setOption(QSurfaceFormat::DebugContext);
|
||||
|
||||
|
|
Loading…
Reference in a new issue