2022-06-08 12:47:24 +00:00
|
|
|
// Copyright (C) 2017 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2017-02-06 11:41:56 +00:00
|
|
|
|
|
|
|
#include <QGuiApplication>
|
|
|
|
#include <QQuickView>
|
2017-04-25 06:54:55 +00:00
|
|
|
#include <QOpenGLContext>
|
2021-07-10 22:40:45 +00:00
|
|
|
#include <Qt3DRender/qt3drender-config.h>
|
2017-04-25 06:54:55 +00:00
|
|
|
|
|
|
|
void setSurfaceFormat()
|
|
|
|
{
|
|
|
|
QSurfaceFormat format;
|
2020-04-27 10:56:17 +00:00
|
|
|
#if QT_CONFIG(opengles2)
|
2017-04-25 06:54:55 +00:00
|
|
|
format.setRenderableType(QSurfaceFormat::OpenGLES);
|
|
|
|
#else
|
|
|
|
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) {
|
|
|
|
format.setVersion(4, 3);
|
|
|
|
format.setProfile(QSurfaceFormat::CoreProfile);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
format.setDepthBufferSize(24);
|
|
|
|
format.setSamples(4);
|
|
|
|
format.setStencilBufferSize(8);
|
|
|
|
QSurfaceFormat::setDefaultFormat(format);
|
2021-07-10 22:40:45 +00:00
|
|
|
|
|
|
|
#if !QT_CONFIG(qt3d_rhi_renderer)
|
|
|
|
qputenv("QSG_RHI_BACKEND", "opengl");
|
|
|
|
#endif
|
2017-04-25 06:54:55 +00:00
|
|
|
}
|
2017-02-06 11:41:56 +00:00
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
QGuiApplication app(argc, argv);
|
2017-05-08 06:26:44 +00:00
|
|
|
setSurfaceFormat();
|
2017-02-06 11:41:56 +00:00
|
|
|
|
|
|
|
QQuickView view;
|
|
|
|
|
|
|
|
view.resize(1920, 1080);
|
|
|
|
view.setResizeMode(QQuickView::SizeRootObjectToView);
|
|
|
|
view.setSource(QUrl("qrc:/main.qml"));
|
|
|
|
view.show();
|
|
|
|
|
|
|
|
return app.exec();
|
|
|
|
}
|