diff options
Diffstat (limited to 'src/extras/defaults')
-rw-r--r-- | src/extras/defaults/defaults.pri | 1 | ||||
-rw-r--r-- | src/extras/defaults/qskyboxentity.cpp | 2 | ||||
-rw-r--r-- | src/extras/defaults/qt3dwindow.cpp | 80 | ||||
-rw-r--r-- | src/extras/defaults/qt3dwindow.h | 25 | ||||
-rw-r--r-- | src/extras/defaults/qt3dwindow_p.h | 92 |
5 files changed, 147 insertions, 53 deletions
diff --git a/src/extras/defaults/defaults.pri b/src/extras/defaults/defaults.pri index ec8c9a7b5..8a18fb6e9 100644 --- a/src/extras/defaults/defaults.pri +++ b/src/extras/defaults/defaults.pri @@ -24,6 +24,7 @@ HEADERS += \ $$PWD/qphongalphamaterial.h \ $$PWD/qphongalphamaterial_p.h \ $$PWD/qt3dwindow.h \ + $$PWD/qt3dwindow_p.h \ $$PWD/qfirstpersoncameracontroller.h \ $$PWD/qfirstpersoncameracontroller_p.h \ $$PWD/qorbitcameracontroller.h \ diff --git a/src/extras/defaults/qskyboxentity.cpp b/src/extras/defaults/qskyboxentity.cpp index ae3fa1087..3c7b0dd4e 100644 --- a/src/extras/defaults/qskyboxentity.cpp +++ b/src/extras/defaults/qskyboxentity.cpp @@ -138,10 +138,8 @@ void QSkyboxEntityPrivate::init() m_gl3RenderPass->addRenderState(seamlessCubemap); m_gl2RenderPass->addRenderState(cullFront); m_gl2RenderPass->addRenderState(depthTest); - m_gl2RenderPass->addRenderState(seamlessCubemap); m_es2RenderPass->addRenderState(cullFront); m_es2RenderPass->addRenderState(depthTest); - m_es2RenderPass->addRenderState(seamlessCubemap); m_gl3Technique->addRenderPass(m_gl3RenderPass); m_gl2Technique->addRenderPass(m_gl2RenderPass); diff --git a/src/extras/defaults/qt3dwindow.cpp b/src/extras/defaults/qt3dwindow.cpp index a0ce40e16..635d81956 100644 --- a/src/extras/defaults/qt3dwindow.cpp +++ b/src/extras/defaults/qt3dwindow.cpp @@ -49,6 +49,7 @@ ****************************************************************************/ #include "qt3dwindow.h" +#include "qt3dwindow_p.h" #include <Qt3DCore/qaspectengine.h> #include <Qt3DCore/qentity.h> @@ -65,9 +66,8 @@ QT_BEGIN_NAMESPACE namespace Qt3DExtras { -Qt3DWindow::Qt3DWindow(QScreen *screen) - : QWindow(screen) - , m_aspectEngine(new Qt3DCore::QAspectEngine) +Qt3DWindowPrivate::Qt3DWindowPrivate() + : m_aspectEngine(new Qt3DCore::QAspectEngine) , m_renderAspect(new Qt3DRender::QRenderAspect) , m_inputAspect(new Qt3DInput::QInputAspect) , m_logicAspect(new Qt3DLogic::QLogicAspect) @@ -79,6 +79,16 @@ Qt3DWindow::Qt3DWindow(QScreen *screen) , m_userRoot(nullptr) , m_initialized(false) { +} + +Qt3DWindow::Qt3DWindow(QScreen *screen) + : QWindow(*new Qt3DWindowPrivate(), nullptr) +{ + Q_D(Qt3DWindow); + + if (!d->parentWindow) + d->connectToScreen(screen ? screen : d->topLevelScreen.data()); + setSurfaceType(QSurface::OpenGLSurface); resize(1024, 768); @@ -98,77 +108,88 @@ Qt3DWindow::Qt3DWindow(QScreen *screen) setFormat(format); QSurfaceFormat::setDefaultFormat(format); - m_aspectEngine->registerAspect(m_renderAspect); - m_aspectEngine->registerAspect(m_inputAspect); - m_aspectEngine->registerAspect(m_logicAspect); + d->m_aspectEngine->registerAspect(d->m_renderAspect); + d->m_aspectEngine->registerAspect(d->m_inputAspect); + d->m_aspectEngine->registerAspect(d->m_logicAspect); - m_defaultCamera->setParent(m_root); - m_forwardRenderer->setCamera(m_defaultCamera); - m_forwardRenderer->setSurface(this); - m_renderSettings->setActiveFrameGraph(m_forwardRenderer); - m_inputSettings->setEventSource(this); + d->m_defaultCamera->setParent(d->m_root); + d->m_forwardRenderer->setCamera(d->m_defaultCamera); + d->m_forwardRenderer->setSurface(this); + d->m_renderSettings->setActiveFrameGraph(d->m_forwardRenderer); + d->m_inputSettings->setEventSource(this); } Qt3DWindow::~Qt3DWindow() { + Q_D(Qt3DWindow); + delete d->m_aspectEngine; } void Qt3DWindow::registerAspect(Qt3DCore::QAbstractAspect *aspect) { Q_ASSERT(!isVisible()); - m_aspectEngine->registerAspect(aspect); + Q_D(Qt3DWindow); + d->m_aspectEngine->registerAspect(aspect); } void Qt3DWindow::registerAspect(const QString &name) { Q_ASSERT(!isVisible()); - m_aspectEngine->registerAspect(name); + Q_D(Qt3DWindow); + d->m_aspectEngine->registerAspect(name); } void Qt3DWindow::setRootEntity(Qt3DCore::QEntity *root) { - if (m_userRoot != root) { - if (m_userRoot != nullptr) - m_userRoot->setParent(static_cast<Qt3DCore::QNode*>(nullptr)); + Q_D(Qt3DWindow); + if (d->m_userRoot != root) { + if (d->m_userRoot != nullptr) + d->m_userRoot->setParent(static_cast<Qt3DCore::QNode*>(nullptr)); if (root != nullptr) - root->setParent(m_root); - m_userRoot = root; + root->setParent(d->m_root); + d->m_userRoot = root; } } void Qt3DWindow::setActiveFrameGraph(Qt3DRender::QFrameGraphNode *activeFrameGraph) { - m_renderSettings->setActiveFrameGraph(activeFrameGraph); + Q_D(Qt3DWindow); + d->m_renderSettings->setActiveFrameGraph(activeFrameGraph); } Qt3DRender::QFrameGraphNode *Qt3DWindow::activeFrameGraph() const { - return m_renderSettings->activeFrameGraph(); + Q_D(const Qt3DWindow); + return d->m_renderSettings->activeFrameGraph(); } Qt3DExtras::QForwardRenderer *Qt3DWindow::defaultFrameGraph() const { - return m_forwardRenderer; + Q_D(const Qt3DWindow); + return d->m_forwardRenderer; } Qt3DRender::QCamera *Qt3DWindow::camera() const { - return m_defaultCamera; + Q_D(const Qt3DWindow); + return d->m_defaultCamera; } Qt3DRender::QRenderSettings *Qt3DWindow::renderSettings() const { - return m_renderSettings; + Q_D(const Qt3DWindow); + return d->m_renderSettings; } void Qt3DWindow::showEvent(QShowEvent *e) { - if (!m_initialized) { - m_root->addComponent(m_renderSettings); - m_root->addComponent(m_inputSettings); - m_aspectEngine->setRootEntity(Qt3DCore::QEntityPtr(m_root)); + Q_D(Qt3DWindow); + if (!d->m_initialized) { + d->m_root->addComponent(d->m_renderSettings); + d->m_root->addComponent(d->m_inputSettings); + d->m_aspectEngine->setRootEntity(Qt3DCore::QEntityPtr(d->m_root)); - m_initialized = true; + d->m_initialized = true; } QWindow::showEvent(e); @@ -176,7 +197,8 @@ void Qt3DWindow::showEvent(QShowEvent *e) void Qt3DWindow::resizeEvent(QResizeEvent *) { - m_defaultCamera->setAspectRatio(float(width()) / float(height())); + Q_D(Qt3DWindow); + d->m_defaultCamera->setAspectRatio(float(width()) / float(height())); } } // Qt3DExtras diff --git a/src/extras/defaults/qt3dwindow.h b/src/extras/defaults/qt3dwindow.h index 811bb134d..6ec1bbf8b 100644 --- a/src/extras/defaults/qt3dwindow.h +++ b/src/extras/defaults/qt3dwindow.h @@ -84,6 +84,8 @@ class QLogicAspect; namespace Qt3DExtras { +class Qt3DWindowPrivate; + class QT3DEXTRASSHARED_EXPORT Qt3DWindow : public QWindow { Q_OBJECT @@ -112,28 +114,7 @@ protected: void resizeEvent(QResizeEvent *) Q_DECL_OVERRIDE; private: - QScopedPointer<Qt3DCore::QAspectEngine> m_aspectEngine; - - // Aspects - Qt3DRender::QRenderAspect *m_renderAspect; - Qt3DInput::QInputAspect *m_inputAspect; - Qt3DLogic::QLogicAspect *m_logicAspect; - - // Renderer configuration - Qt3DRender::QRenderSettings *m_renderSettings; - Qt3DExtras::QForwardRenderer *m_forwardRenderer; - Qt3DRender::QCamera *m_defaultCamera; - - // Input configuration - Qt3DInput::QInputSettings *m_inputSettings; - - // Logic configuration - - // Scene - Qt3DCore::QEntity *m_root; - Qt3DCore::QEntity *m_userRoot; - - bool m_initialized; + Q_DECLARE_PRIVATE(Qt3DWindow) }; } // Qt3DExtras diff --git a/src/extras/defaults/qt3dwindow_p.h b/src/extras/defaults/qt3dwindow_p.h new file mode 100644 index 000000000..731d5298e --- /dev/null +++ b/src/extras/defaults/qt3dwindow_p.h @@ -0,0 +1,92 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the Qt3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QT3DWINDOW_P_H +#define QT3DWINDOW_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists for the convenience +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtGui/private/qwindow_p.h> + +QT_BEGIN_NAMESPACE + +namespace Qt3DExtras { + +class Qt3DWindowPrivate : public QWindowPrivate +{ +public: + Qt3DWindowPrivate(); + + Qt3DCore::QAspectEngine *m_aspectEngine; + + // Aspects + Qt3DRender::QRenderAspect *m_renderAspect; + Qt3DInput::QInputAspect *m_inputAspect; + Qt3DLogic::QLogicAspect *m_logicAspect; + + // Renderer configuration + Qt3DRender::QRenderSettings *m_renderSettings; + Qt3DExtras::QForwardRenderer *m_forwardRenderer; + Qt3DRender::QCamera *m_defaultCamera; + + // Input configuration + Qt3DInput::QInputSettings *m_inputSettings; + + // Logic configuration + + // Scene + Qt3DCore::QEntity *m_root; + Qt3DCore::QEntity *m_userRoot; + + bool m_initialized; + + Q_DECLARE_PUBLIC(Qt3DWindow) +}; + +} // Qt3DExtras + +QT_END_NAMESPACE + +#endif // QT3DWINDOW_P_H |