mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 19:01:09 +02:00
Expose GL property to QML
This commit is contained in:
parent
50a081db00
commit
e08c9db469
7 changed files with 43 additions and 17 deletions
|
@ -199,6 +199,8 @@ static const QString DESKTOP_LOCATION = QStandardPaths::writableLocation(QStanda
|
||||||
static const QString DESKTOP_LOCATION = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation).append("/script.js");
|
static const QString DESKTOP_LOCATION = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation).append("/script.js");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
QJsonObject Application::_glData {};
|
||||||
|
|
||||||
Setting::Handle<int> maxOctreePacketsPerSecond("maxOctreePPS", DEFAULT_MAX_OCTREE_PPS);
|
Setting::Handle<int> maxOctreePacketsPerSecond("maxOctreePPS", DEFAULT_MAX_OCTREE_PPS);
|
||||||
|
|
||||||
const QHash<QString, Application::AcceptURLMethod> Application::_acceptedExtensions {
|
const QHash<QString, Application::AcceptURLMethod> Application::_acceptedExtensions {
|
||||||
|
@ -1303,7 +1305,9 @@ void Application::initializeGL() {
|
||||||
|
|
||||||
InfoView::show(INFO_HELP_PATH, true);
|
InfoView::show(INFO_HELP_PATH, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void setupPreferences();
|
extern void setupPreferences();
|
||||||
|
|
||||||
void Application::initializeUi() {
|
void Application::initializeUi() {
|
||||||
AddressBarDialog::registerType();
|
AddressBarDialog::registerType();
|
||||||
ErrorDialog::registerType();
|
ErrorDialog::registerType();
|
||||||
|
@ -1315,6 +1319,12 @@ void Application::initializeUi() {
|
||||||
|
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
offscreenUi->create(_offscreenContext->getContext());
|
offscreenUi->create(_offscreenContext->getContext());
|
||||||
|
|
||||||
|
auto rootContext = offscreenUi->getRootContext();
|
||||||
|
|
||||||
|
// First set the GL property, so the desktop can use it for graphics workarounds
|
||||||
|
rootContext->setContextProperty("GL", _glData);
|
||||||
|
|
||||||
offscreenUi->setProxyWindow(_window->windowHandle());
|
offscreenUi->setProxyWindow(_window->windowHandle());
|
||||||
offscreenUi->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/"));
|
offscreenUi->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/"));
|
||||||
// OffscreenUi is a subclass of OffscreenQmlSurface specifically designed to
|
// OffscreenUi is a subclass of OffscreenQmlSurface specifically designed to
|
||||||
|
@ -1325,7 +1335,6 @@ void Application::initializeUi() {
|
||||||
// do better detection in the offscreen UI of what has focus
|
// do better detection in the offscreen UI of what has focus
|
||||||
offscreenUi->setNavigationFocused(false);
|
offscreenUi->setNavigationFocused(false);
|
||||||
|
|
||||||
auto rootContext = offscreenUi->getRootContext();
|
|
||||||
auto engine = rootContext->engine();
|
auto engine = rootContext->engine();
|
||||||
connect(engine, &QQmlEngine::quit, [] {
|
connect(engine, &QQmlEngine::quit, [] {
|
||||||
qApp->quit();
|
qApp->quit();
|
||||||
|
|
|
@ -96,6 +96,9 @@ public:
|
||||||
static void initPlugins();
|
static void initPlugins();
|
||||||
static void shutdownPlugins();
|
static void shutdownPlugins();
|
||||||
|
|
||||||
|
// Expose the gl metadata to QML
|
||||||
|
static void setGL(const QJsonObject& glData) { _glData = glData; }
|
||||||
|
|
||||||
Application(int& argc, char** argv, QElapsedTimer& startup_time);
|
Application(int& argc, char** argv, QElapsedTimer& startup_time);
|
||||||
~Application();
|
~Application();
|
||||||
|
|
||||||
|
@ -379,6 +382,8 @@ private:
|
||||||
|
|
||||||
void maybeToggleMenuVisible(QMouseEvent* event) const;
|
void maybeToggleMenuVisible(QMouseEvent* event) const;
|
||||||
|
|
||||||
|
static QJsonObject _glData;
|
||||||
|
|
||||||
MainWindow* _window;
|
MainWindow* _window;
|
||||||
QElapsedTimer& _sessionRunTimer;
|
QElapsedTimer& _sessionRunTimer;
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ int main(int argc, const char* argv[]) {
|
||||||
MiniDmpSender mpSender { BUG_SPLAT_DATABASE, BUG_SPLAT_APPLICATION_NAME, qPrintable(BuildInfo::VERSION),
|
MiniDmpSender mpSender { BUG_SPLAT_DATABASE, BUG_SPLAT_APPLICATION_NAME, qPrintable(BuildInfo::VERSION),
|
||||||
nullptr, BUG_SPLAT_FLAGS };
|
nullptr, BUG_SPLAT_FLAGS };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QString applicationName = "High Fidelity Interface - " + qgetenv("USERNAME");
|
QString applicationName = "High Fidelity Interface - " + qgetenv("USERNAME");
|
||||||
|
|
||||||
bool instanceMightBeRunning = true;
|
bool instanceMightBeRunning = true;
|
||||||
|
@ -105,13 +105,14 @@ int main(int argc, const char* argv[]) {
|
||||||
// This is done separately from the main Application so that start-up and shut-down logic within the main Application is
|
// 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.
|
// not made more complicated than it already is.
|
||||||
bool override = false;
|
bool override = false;
|
||||||
QString glVersion;
|
QJsonObject glData;
|
||||||
{
|
{
|
||||||
OpenGLVersionChecker openGLVersionChecker(argc, const_cast<char**>(argv));
|
OpenGLVersionChecker openGLVersionChecker(argc, const_cast<char**>(argv));
|
||||||
bool valid = true;
|
bool valid = true;
|
||||||
glVersion = openGLVersionChecker.checkVersion(valid, override);
|
glData = openGLVersionChecker.checkVersion(valid, override);
|
||||||
if (!valid) {
|
if (!valid) {
|
||||||
if (override) {
|
if (override) {
|
||||||
|
auto glVersion = glData["version"].toString();
|
||||||
qCDebug(interfaceapp, "Running on insufficient OpenGL version: %s.", glVersion.toStdString().c_str());
|
qCDebug(interfaceapp, "Running on insufficient OpenGL version: %s.", glVersion.toStdString().c_str());
|
||||||
} else {
|
} else {
|
||||||
qCDebug(interfaceapp, "Early exit due to OpenGL version.");
|
qCDebug(interfaceapp, "Early exit due to OpenGL version.");
|
||||||
|
@ -139,21 +140,23 @@ int main(int argc, const char* argv[]) {
|
||||||
// or in the main window ctor, before GL startup.
|
// or in the main window ctor, before GL startup.
|
||||||
Application::initPlugins();
|
Application::initPlugins();
|
||||||
|
|
||||||
|
// GL must be available to the root QML context on startup.
|
||||||
|
Application::setGL(glData);
|
||||||
|
|
||||||
int exitCode;
|
int exitCode;
|
||||||
{
|
{
|
||||||
QSettings::setDefaultFormat(QSettings::IniFormat);
|
QSettings::setDefaultFormat(QSettings::IniFormat);
|
||||||
Application app(argc, const_cast<char**>(argv), startupTime);
|
Application app(argc, const_cast<char**>(argv), startupTime);
|
||||||
|
|
||||||
// If we failed the OpenGLVersion check, log it.
|
// If we failed the OpenGLVersion check, log it.
|
||||||
if (override) {
|
if (override) {
|
||||||
auto& accountManager = AccountManager::getInstance();
|
auto& accountManager = AccountManager::getInstance();
|
||||||
if (accountManager.isLoggedIn()) {
|
if (accountManager.isLoggedIn()) {
|
||||||
UserActivityLogger::getInstance().insufficientGLVersion(glVersion);
|
UserActivityLogger::getInstance().insufficientGLVersion(glData);
|
||||||
} else {
|
} else {
|
||||||
QObject::connect(&AccountManager::getInstance(), &AccountManager::loginComplete, [glVersion](){
|
QObject::connect(&AccountManager::getInstance(), &AccountManager::loginComplete, [glData](){
|
||||||
static bool loggedInsufficientGL = false;
|
static bool loggedInsufficientGL = false;
|
||||||
if (!loggedInsufficientGL) {
|
if (!loggedInsufficientGL) {
|
||||||
UserActivityLogger::getInstance().insufficientGLVersion(glVersion);
|
UserActivityLogger::getInstance().insufficientGLVersion(glData);
|
||||||
loggedInsufficientGL = true;
|
loggedInsufficientGL = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QRegularExpression>
|
#include <QRegularExpression>
|
||||||
|
#include <QJsonObject>
|
||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "GLWidget.h"
|
#include "GLWidget.h"
|
||||||
|
@ -22,7 +23,7 @@ OpenGLVersionChecker::OpenGLVersionChecker(int& argc, char** argv) :
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QString OpenGLVersionChecker::checkVersion(bool& valid, bool& override) {
|
QJsonObject OpenGLVersionChecker::checkVersion(bool& valid, bool& override) {
|
||||||
valid = true;
|
valid = true;
|
||||||
override = false;
|
override = false;
|
||||||
|
|
||||||
|
@ -38,12 +39,15 @@ QString OpenGLVersionChecker::checkVersion(bool& valid, bool& override) {
|
||||||
messageBox.setStandardButtons(QMessageBox::Ok);
|
messageBox.setStandardButtons(QMessageBox::Ok);
|
||||||
messageBox.setDefaultButton(QMessageBox::Ok);
|
messageBox.setDefaultButton(QMessageBox::Ok);
|
||||||
messageBox.exec();
|
messageBox.exec();
|
||||||
return QString();
|
return QJsonObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve OpenGL version
|
// Retrieve OpenGL version
|
||||||
glWidget->initializeGL();
|
glWidget->initializeGL();
|
||||||
QString glVersion = QString((const char*)glGetString(GL_VERSION));
|
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));
|
||||||
delete glWidget;
|
delete glWidget;
|
||||||
|
|
||||||
// Compare against minimum
|
// Compare against minimum
|
||||||
|
@ -72,5 +76,10 @@ QString OpenGLVersionChecker::checkVersion(bool& valid, bool& override) {
|
||||||
override = messageBox.exec() == QMessageBox::Ignore;
|
override = messageBox.exec() == QMessageBox::Ignore;
|
||||||
}
|
}
|
||||||
|
|
||||||
return glVersion;
|
return QJsonObject{
|
||||||
|
{ "version", glVersion },
|
||||||
|
{ "slVersion", glslVersion },
|
||||||
|
{ "vendor", glVendor },
|
||||||
|
{ "renderer", glRenderer },
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ class OpenGLVersionChecker : public QApplication {
|
||||||
public:
|
public:
|
||||||
OpenGLVersionChecker(int& argc, char** argv);
|
OpenGLVersionChecker(int& argc, char** argv);
|
||||||
|
|
||||||
static QString checkVersion(bool& valid, bool& override);
|
static QJsonObject checkVersion(bool& valid, bool& override);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_OpenGLVersionChecker_h
|
#endif // hifi_OpenGLVersionChecker_h
|
||||||
|
|
|
@ -85,11 +85,11 @@ void UserActivityLogger::launch(QString applicationVersion, bool previousSession
|
||||||
logAction(ACTION_NAME, actionDetails);
|
logAction(ACTION_NAME, actionDetails);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UserActivityLogger::insufficientGLVersion(QString glVersion) {
|
void UserActivityLogger::insufficientGLVersion(const QJsonObject& glData) {
|
||||||
const QString ACTION_NAME = "insufficient_gl";
|
const QString ACTION_NAME = "insufficient_gl";
|
||||||
QJsonObject actionDetails;
|
QJsonObject actionDetails;
|
||||||
QString GL_VERSION = "glVersion";
|
QString GL_DATA = "glData";
|
||||||
actionDetails.insert(GL_VERSION, glVersion);
|
actionDetails.insert(GL_DATA, glData);
|
||||||
|
|
||||||
logAction(ACTION_NAME, actionDetails);
|
logAction(ACTION_NAME, actionDetails);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ public slots:
|
||||||
|
|
||||||
void launch(QString applicationVersion, bool previousSessionCrashed, int previousSessionRuntime);
|
void launch(QString applicationVersion, bool previousSessionCrashed, int previousSessionRuntime);
|
||||||
|
|
||||||
void insufficientGLVersion(QString glVersion);
|
void insufficientGLVersion(const QJsonObject& glData);
|
||||||
|
|
||||||
void changedDisplayName(QString displayName);
|
void changedDisplayName(QString displayName);
|
||||||
void changedModel(QString typeOfModel, QString modelURL);
|
void changedModel(QString typeOfModel, QString modelURL);
|
||||||
|
@ -48,4 +48,4 @@ private:
|
||||||
bool _disabled;
|
bool _disabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_UserActivityLogger_h
|
#endif // hifi_UserActivityLogger_h
|
||||||
|
|
Loading…
Reference in a new issue