mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 17:56:43 +02:00
Merge pull request #6965 from ctrlaltdavid/20793
Warn user if OpenGL version is too low (< 4.1)
This commit is contained in:
commit
e97850dd26
4 changed files with 100 additions and 0 deletions
|
@ -17,6 +17,7 @@
|
||||||
#include <QSharedMemory>
|
#include <QSharedMemory>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
|
|
||||||
|
#include <gl/OpenGLVersionChecker.h>
|
||||||
#include <SharedUtil.h>
|
#include <SharedUtil.h>
|
||||||
|
|
||||||
#include "AddressManager.h"
|
#include "AddressManager.h"
|
||||||
|
@ -83,6 +84,17 @@ int main(int argc, const char* argv[]) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check OpenGL version.
|
||||||
|
// This is done separately from the main Application so that start-up and shut-down logic within the main Application is
|
||||||
|
// not made more complicated than it already is.
|
||||||
|
{
|
||||||
|
OpenGLVersionChecker openGLVersionChecker(argc, const_cast<char**>(argv));
|
||||||
|
if (!openGLVersionChecker.isValidVersion()) {
|
||||||
|
qCDebug(interfaceapp, "Early exit due to OpenGL version.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QElapsedTimer startupTime;
|
QElapsedTimer startupTime;
|
||||||
startupTime.start();
|
startupTime.start();
|
||||||
|
|
||||||
|
@ -96,6 +108,7 @@ int main(int argc, const char* argv[]) {
|
||||||
usecTimestampNowForceClockSkew(clockSkew);
|
usecTimestampNowForceClockSkew(clockSkew);
|
||||||
qCDebug(interfaceapp, "clockSkewOption=%s clockSkew=%d", clockSkewOption, clockSkew);
|
qCDebug(interfaceapp, "clockSkewOption=%s clockSkew=%d", clockSkewOption, clockSkew);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Oculus initialization MUST PRECEDE OpenGL context creation.
|
// Oculus initialization MUST PRECEDE OpenGL context creation.
|
||||||
// The nature of the Application constructor means this has to be either here,
|
// The nature of the Application constructor means this has to be either here,
|
||||||
// or in the main window ctor, before GL startup.
|
// or in the main window ctor, before GL startup.
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#define GPU_LEGACY 0
|
#define GPU_LEGACY 0
|
||||||
#define GPU_CORE_41 410
|
#define GPU_CORE_41 410
|
||||||
#define GPU_CORE_43 430
|
#define GPU_CORE_43 430
|
||||||
|
#define GPU_CORE_MINIMUM GPU_CORE_41
|
||||||
|
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
|
|
||||||
|
|
61
libraries/gl/src/gl/OpenGLVersionChecker.cpp
Normal file
61
libraries/gl/src/gl/OpenGLVersionChecker.cpp
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
//
|
||||||
|
// OpenGLVersionChecker.cpp
|
||||||
|
// libraries/gl/src/gl
|
||||||
|
//
|
||||||
|
// Created by David Rowe on 28 Jan 2016.
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "OpenGLVersionChecker.h"
|
||||||
|
|
||||||
|
#include <QMessageBox>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
|
#include "Config.h"
|
||||||
|
#include "GLWidget.h"
|
||||||
|
|
||||||
|
OpenGLVersionChecker::OpenGLVersionChecker(int& argc, char** argv) :
|
||||||
|
QApplication(argc, argv)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OpenGLVersionChecker::isValidVersion() {
|
||||||
|
bool valid = true;
|
||||||
|
|
||||||
|
// Retrieve OpenGL version
|
||||||
|
GLWidget* glWidget = new GLWidget();
|
||||||
|
glWidget->initializeGL();
|
||||||
|
QString glVersion = QString((const char*)glGetString(GL_VERSION));
|
||||||
|
delete glWidget;
|
||||||
|
|
||||||
|
// Compare against minimum
|
||||||
|
// The GL_VERSION string begins with a version number in one of these forms:
|
||||||
|
// - major_number.minor_number
|
||||||
|
// - major_number.minor_number.release_number
|
||||||
|
// Reference: https://www.opengl.org/sdk/docs/man/docbook4/xhtml/glGetString.xml
|
||||||
|
QStringList versionParts = glVersion.split(QRegularExpression("[\\.\\s]"));
|
||||||
|
int majorNumber = versionParts[0].toInt();
|
||||||
|
int minorNumber = versionParts[1].toInt();
|
||||||
|
int minimumMajorNumber = GPU_CORE_MINIMUM / 100;
|
||||||
|
int minimumMinorNumber = (GPU_CORE_MINIMUM - minimumMajorNumber * 100) / 10;
|
||||||
|
valid = (majorNumber > minimumMajorNumber
|
||||||
|
|| (majorNumber == minimumMajorNumber && minorNumber >= minimumMinorNumber));
|
||||||
|
|
||||||
|
// Prompt user if below minimum
|
||||||
|
if (!valid) {
|
||||||
|
QMessageBox messageBox;
|
||||||
|
messageBox.setWindowTitle("OpenGL Version Too Low");
|
||||||
|
messageBox.setIcon(QMessageBox::Warning);
|
||||||
|
messageBox.setText(QString().sprintf("Your OpenGL version of %i.%i is lower than the minimum of %i.%i.",
|
||||||
|
majorNumber, minorNumber, minimumMajorNumber, minimumMinorNumber));
|
||||||
|
messageBox.setInformativeText("Press OK to exit; Ignore to continue.");
|
||||||
|
messageBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Ignore);
|
||||||
|
messageBox.setDefaultButton(QMessageBox::Ok);
|
||||||
|
valid = messageBox.exec() == QMessageBox::Ignore;
|
||||||
|
}
|
||||||
|
|
||||||
|
return valid;
|
||||||
|
}
|
25
libraries/gl/src/gl/OpenGLVersionChecker.h
Normal file
25
libraries/gl/src/gl/OpenGLVersionChecker.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
//
|
||||||
|
// OpenGLVersionChecker.h
|
||||||
|
// libraries/gl/src/gl
|
||||||
|
//
|
||||||
|
// Created by David Rowe on 28 Jan 2016.
|
||||||
|
// Copyright 2016 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef hifi_OpenGLVersionChecker_h
|
||||||
|
#define hifi_OpenGLVersionChecker_h
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
|
|
||||||
|
class OpenGLVersionChecker : public QApplication {
|
||||||
|
|
||||||
|
public:
|
||||||
|
OpenGLVersionChecker(int& argc, char** argv);
|
||||||
|
|
||||||
|
static bool isValidVersion();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_OpenGLVersionChecker_h
|
Loading…
Reference in a new issue