Commit 5d7c05bc authored by Tomi Korpipää's avatar Tomi Korpipää

Fix kria for macOS

parent 414bc791
......@@ -50,9 +50,56 @@
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QtGui/QFontDatabase>
#include <QtGui/QOpenGLContext>
static QSurfaceFormat findIdealGLVersion()
{
QSurfaceFormat fmt;
fmt.setProfile(QSurfaceFormat::CoreProfile);
// Advanced: Try 4.3 core (so we get compute shaders for instance)
fmt.setVersion(4, 3);
QOpenGLContext ctx;
ctx.setFormat(fmt);
if (ctx.create() && ctx.format().version() >= qMakePair(4, 3))
return fmt;
// Basic: Stick with 3.3 for now to keep less fortunate,
// Mesa-based systems happy
fmt.setVersion(3, 3);
ctx.setFormat(fmt);
if (ctx.create())
return fmt;
// We tried...
return QSurfaceFormat::defaultFormat();
}
static QSurfaceFormat findIdealGLESVersion()
{
QSurfaceFormat fmt;
// Advanced: Try 3.1 (so we get compute shaders for instance)
fmt.setVersion(3, 1);
QOpenGLContext ctx;
ctx.setFormat(fmt);
if (ctx.create())
return fmt;
// Basic: OpenGL ES 3.0 is a hard requirement at the moment since we can
// only generate 300 es shaders, uniform buffers are mandatory.
fmt.setVersion(3, 0);
ctx.setFormat(fmt);
if (ctx.create())
return fmt;
// We tried...
return QSurfaceFormat::defaultFormat();
}
int main(int argc, char *argv[])
{
#if 0 // For B2Qt & QNX
qputenv("QT_QPA_EGLFS_HIDECURSOR", "1");
// qputenv("QT_QPA_EGLFS_DISABLE_INPUT", "1");
qputenv("QT_QPA_EGLFS_WIDTH", "1920");
......@@ -69,10 +116,32 @@ int main(int argc, char *argv[])
// Disable all extra logging
// qputenv("QT_LOGGING_RULES", "*=false");
// QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
#if defined(Q_OS_MACOS)
QSurfaceFormat openGLFormat;
openGLFormat.setRenderableType(QSurfaceFormat::OpenGL);
openGLFormat.setProfile(QSurfaceFormat::CoreProfile);
openGLFormat.setMajorVersion(4);
openGLFormat.setMinorVersion(1);
openGLFormat.setStencilBufferSize(8);
QSurfaceFormat::setDefaultFormat(openGLFormat);
#endif
QGuiApplication app(argc, argv);
#if !defined(Q_OS_MACOS)
QSurfaceFormat fmt;
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL)
fmt = findIdealGLVersion();
else
fmt = findIdealGLESVersion();
fmt.setDepthBufferSize(24);
fmt.setStencilBufferSize(8);
QSurfaceFormat::setDefaultFormat(fmt);
#endif
QFontDatabase::addApplicationFont("qrc:/presentation/fonts/TitilliumWeb-Regular.ttf");
QFont defaultFont;
defaultFont.setFamily("Titillium Web");
......
......@@ -51,7 +51,6 @@
import QtQuick 2.12
import QtQuick.Window 2.12
import QtStudio3D.OpenGL 2.4
import QtQuick.Controls 2.1
Window {
id: mainview
......@@ -60,7 +59,7 @@ Window {
visible: true
color: "#000000"
title: "Qt 3D Studio Kria 3D Cluster Demo"
//visibility: Window.FullScreen
// visibility: Window.FullScreen
property bool startupAnimation: true
property bool allowSelection: true
......@@ -197,30 +196,6 @@ Window {
visible: false
}
Keys.onRightPressed: {
userActivity();
menuSelect(true);
}
Keys.onLeftPressed: {
userActivity();
menuSelect(false);
}
Keys.onUpPressed: {
userActivity();
selectedMenuIndex--;
if (selectedMenuIndex < 0)
selectedMenuIndex = 0;
}
Keys.onDownPressed: {
userActivity();
selectedMenuIndex++;
if (selectedMenuIndex > maxMenuIndex)
selectedMenuIndex = maxMenuIndex;
}
// Simulated speed and rpm data
SimuData {
id: simuData
......@@ -364,12 +339,37 @@ Window {
MouseArea {
anchors.fill: parent
focus: true
z: 100
onPressed: {
// Record user activity and pass event further
userActivity();
mouse.accepted = false;
}
Keys.onRightPressed: {
userActivity();
menuSelect(true);
}
Keys.onLeftPressed: {
userActivity();
menuSelect(false);
}
Keys.onUpPressed: {
userActivity();
selectedMenuIndex--;
if (selectedMenuIndex < 0)
selectedMenuIndex = 0;
}
Keys.onDownPressed: {
userActivity();
selectedMenuIndex++;
if (selectedMenuIndex > maxMenuIndex)
selectedMenuIndex = maxMenuIndex;
}
}
//
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment