mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 20:58:38 +02:00
Move gl info queries to GLHelpers
This commit is contained in:
parent
d719b3692e
commit
52958ffc70
3 changed files with 28 additions and 10 deletions
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include <QtGui/QSurfaceFormat>
|
#include <QtGui/QSurfaceFormat>
|
||||||
#include <QtOpenGL/QGL>
|
#include <QtOpenGL/QGL>
|
||||||
|
#include <QOpenGLContext>
|
||||||
|
|
||||||
const QSurfaceFormat& getDefaultOpenGLSurfaceFormat() {
|
const QSurfaceFormat& getDefaultOpenGLSurfaceFormat() {
|
||||||
static QSurfaceFormat format;
|
static QSurfaceFormat format;
|
||||||
|
@ -35,3 +36,21 @@ const QGLFormat& getDefaultGLFormat() {
|
||||||
});
|
});
|
||||||
return glFormat;
|
return glFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QJsonObject getGLContextData() {
|
||||||
|
if (!QOpenGLContext::currentContext()) {
|
||||||
|
return QJsonObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString glVersion = QString((const char*)glGetString(GL_VERSION));
|
||||||
|
QString glslVersion = QString((const char*) glGetString(GL_SHADING_LANGUAGE_VERSION));
|
||||||
|
QString glVendor = QString((const char*) glGetString(GL_VENDOR));
|
||||||
|
QString glRenderer = QString((const char*)glGetString(GL_RENDERER));
|
||||||
|
|
||||||
|
return QJsonObject {
|
||||||
|
{ "version", glVersion },
|
||||||
|
{ "slVersion", glslVersion },
|
||||||
|
{ "vendor", glVendor },
|
||||||
|
{ "renderer", glRenderer },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
#ifndef hifi_GLHelpers_h
|
#ifndef hifi_GLHelpers_h
|
||||||
#define hifi_GLHelpers_h
|
#define hifi_GLHelpers_h
|
||||||
|
|
||||||
|
#include <QJsonObject>
|
||||||
|
|
||||||
// 16 bits of depth precision
|
// 16 bits of depth precision
|
||||||
#define DEFAULT_GL_DEPTH_BUFFER_BITS 16
|
#define DEFAULT_GL_DEPTH_BUFFER_BITS 16
|
||||||
// 8 bits of stencil buffer (typically you really only need 1 bit for functionality
|
// 8 bits of stencil buffer (typically you really only need 1 bit for functionality
|
||||||
|
@ -21,4 +23,6 @@ class QGLFormat;
|
||||||
|
|
||||||
const QSurfaceFormat& getDefaultOpenGLSurfaceFormat();
|
const QSurfaceFormat& getDefaultOpenGLSurfaceFormat();
|
||||||
const QGLFormat& getDefaultGLFormat();
|
const QGLFormat& getDefaultGLFormat();
|
||||||
|
QJsonObject getGLContextData();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "GLWidget.h"
|
#include "GLWidget.h"
|
||||||
|
#include "GLHelpers.h"
|
||||||
|
|
||||||
OpenGLVersionChecker::OpenGLVersionChecker(int& argc, char** argv) :
|
OpenGLVersionChecker::OpenGLVersionChecker(int& argc, char** argv) :
|
||||||
QApplication(argc, argv)
|
QApplication(argc, argv)
|
||||||
|
@ -44,10 +45,7 @@ QJsonObject OpenGLVersionChecker::checkVersion(bool& valid, bool& override) {
|
||||||
|
|
||||||
// Retrieve OpenGL version
|
// Retrieve OpenGL version
|
||||||
glWidget->initializeGL();
|
glWidget->initializeGL();
|
||||||
QString glVersion = QString((const char*)glGetString(GL_VERSION));
|
QJsonObject glData = getGLContextData();
|
||||||
QString glslVersion = QString((const char*) glGetString(GL_SHADING_LANGUAGE_VERSION));
|
|
||||||
QString glVendor = QString((const char*) glGetString(GL_VENDOR));
|
|
||||||
QString glRenderer = QString((const char*)glGetString(GL_RENDERER));
|
|
||||||
delete glWidget;
|
delete glWidget;
|
||||||
|
|
||||||
// Compare against minimum
|
// Compare against minimum
|
||||||
|
@ -55,6 +53,8 @@ QJsonObject OpenGLVersionChecker::checkVersion(bool& valid, bool& override) {
|
||||||
// - major_number.minor_number
|
// - major_number.minor_number
|
||||||
// - major_number.minor_number.release_number
|
// - major_number.minor_number.release_number
|
||||||
// Reference: https://www.opengl.org/sdk/docs/man/docbook4/xhtml/glGetString.xml
|
// Reference: https://www.opengl.org/sdk/docs/man/docbook4/xhtml/glGetString.xml
|
||||||
|
const QString version { "version" };
|
||||||
|
QString glVersion = glData[version].toString();
|
||||||
QStringList versionParts = glVersion.split(QRegularExpression("[\\.\\s]"));
|
QStringList versionParts = glVersion.split(QRegularExpression("[\\.\\s]"));
|
||||||
int majorNumber = versionParts[0].toInt();
|
int majorNumber = versionParts[0].toInt();
|
||||||
int minorNumber = versionParts[1].toInt();
|
int minorNumber = versionParts[1].toInt();
|
||||||
|
@ -76,10 +76,5 @@ QJsonObject OpenGLVersionChecker::checkVersion(bool& valid, bool& override) {
|
||||||
override = messageBox.exec() == QMessageBox::Ignore;
|
override = messageBox.exec() == QMessageBox::Ignore;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QJsonObject{
|
return glData;
|
||||||
{ "version", glVersion },
|
|
||||||
{ "slVersion", glslVersion },
|
|
||||||
{ "vendor", glVendor },
|
|
||||||
{ "renderer", glRenderer },
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue