summaryrefslogtreecommitdiffstats
path: root/examples/qt3d/basicshapes-cpp
diff options
context:
space:
mode:
authorKevin Ottens <kevin.ottens@kdab.com>2015-12-28 08:12:34 +0100
committerSean Harmer <sean.harmer@kdab.com>2016-01-13 14:20:09 +0000
commit71b4e8612e558115edd12e8ac19f8d6abe583475 (patch)
tree76826eb7111bda149c279a480eebaa02dc6959dd /examples/qt3d/basicshapes-cpp
parenta57538409a79be1035b70ff79313f2cf8d731e85 (diff)
Port all the pure C++ examples to Qt3DRender::QWindow
Change-Id: I43b4a5fcfb4ec00ccaec013cb31d00ca92d3c224 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'examples/qt3d/basicshapes-cpp')
-rw-r--r--examples/qt3d/basicshapes-cpp/main.cpp24
1 files changed, 6 insertions, 18 deletions
diff --git a/examples/qt3d/basicshapes-cpp/main.cpp b/examples/qt3d/basicshapes-cpp/main.cpp
index cf711172d..f7e50fdd5 100644
--- a/examples/qt3d/basicshapes-cpp/main.cpp
+++ b/examples/qt3d/basicshapes-cpp/main.cpp
@@ -38,7 +38,6 @@
#include <QGuiApplication>
-#include <window.h>
#include <Qt3DCore/qcamera.h>
#include <Qt3DCore/qentity.h>
#include <Qt3DCore/qcameralens.h>
@@ -60,6 +59,7 @@
#include <Qt3DRender/qtexture.h>
#include <Qt3DRender/qrenderpass.h>
#include <Qt3DRender/qsceneloader.h>
+#include <Qt3DRender/qwindow.h>
#include <Qt3DCore/qtransform.h>
#include <Qt3DCore/qaspectengine.h>
@@ -71,7 +71,7 @@
int main(int argc, char **argv)
{
QApplication app(argc, argv);
- Window *view = new Window();
+ Qt3DRender::QWindow *view = new Qt3DRender::QWindow();
QWidget *container = QWidget::createWindowContainer(view);
QSize screenSize = view->screen()->size();
container->setMinimumSize(QSize(200, 100));
@@ -86,21 +86,14 @@ int main(int argc, char **argv)
widget->setWindowTitle(QStringLiteral("Basic shapes"));
- Qt3DCore::QAspectEngine engine;
- engine.registerAspect(new Qt3DRender::QRenderAspect());
Qt3DInput::QInputAspect *input = new Qt3DInput::QInputAspect;
- engine.registerAspect(input);
- QVariantMap data;
- data.insert(QStringLiteral("surface"), QVariant::fromValue(static_cast<QSurface *>(view)));
- data.insert(QStringLiteral("eventSource"), QVariant::fromValue(view));
- engine.setData(data);
+ view->registerAspect(input);
// Root entity
Qt3DCore::QEntity *rootEntity = new Qt3DCore::QEntity();
// Camera
- Qt3DCore::QCamera *cameraEntity = new Qt3DCore::QCamera(rootEntity);
- cameraEntity->setObjectName(QStringLiteral("cameraEntity"));
+ Qt3DCore::QCamera *cameraEntity = view->defaultCamera();
cameraEntity->lens()->setPerspectiveProjection(45.0f, 16.0f/9.0f, 0.1f, 1000.0f);
cameraEntity->setPosition(QVector3D(0, 0, 20.0f));
@@ -117,13 +110,13 @@ int main(int argc, char **argv)
frameGraph->setActiveFrameGraph(forwardRenderer);
// Setting the FrameGraph
- rootEntity->addComponent(frameGraph);
+ view->setFrameGraph(frameGraph);
// Scenemodifier
SceneModifier *modifier = new SceneModifier(rootEntity);
// Set root object of the scene
- engine.setRootEntity(rootEntity);
+ view->setRootEntity(rootEntity);
// Create control widgets
QCommandLinkButton *info = new QCommandLinkButton();
@@ -171,10 +164,5 @@ int main(int argc, char **argv)
widget->show();
widget->resize(1200, 800);
- // Update the aspect ratio
- QSize widgetSize = container->size();
- float aspectRatio = float(widgetSize.width()) / float(widgetSize.height());
- cameraEntity->lens()->setPerspectiveProjection(45.0f, aspectRatio, 0.1f, 1000.0f);
-
return app.exec();
}