mirror of
https://github.com/overte-org/overte.git
synced 2025-04-15 12:28:51 +02:00
Add glVersionToInteger to GLHelpers
This commit is contained in:
parent
ab057010d6
commit
154ccb8932
2 changed files with 9 additions and 0 deletions
|
@ -5,6 +5,7 @@
|
|||
#include <QtGui/QSurfaceFormat>
|
||||
#include <QtOpenGL/QGL>
|
||||
#include <QOpenGLContext>
|
||||
#include <QtCore/QRegularExpression>
|
||||
|
||||
const QSurfaceFormat& getDefaultOpenGLSurfaceFormat() {
|
||||
static QSurfaceFormat format;
|
||||
|
@ -39,6 +40,13 @@ const QGLFormat& getDefaultGLFormat() {
|
|||
return glFormat;
|
||||
}
|
||||
|
||||
int glVersionToInteger(QString glVersion) {
|
||||
QStringList versionParts = glVersion.split(QRegularExpression("[\\.\\s]"));
|
||||
int majorNumber = versionParts[0].toInt();
|
||||
int minorNumber = versionParts[1].toInt();
|
||||
return majorNumber * 100 + minorNumber * 10;
|
||||
}
|
||||
|
||||
QJsonObject getGLContextData() {
|
||||
if (!QOpenGLContext::currentContext()) {
|
||||
return QJsonObject();
|
||||
|
|
|
@ -27,5 +27,6 @@ void setGLFormatVersion(F& format, int major = 4, int minor = 5) { format.setVer
|
|||
const QSurfaceFormat& getDefaultOpenGLSurfaceFormat();
|
||||
const QGLFormat& getDefaultGLFormat();
|
||||
QJsonObject getGLContextData();
|
||||
int glVersionToInteger(QString glVersion);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue