2013-02-27 07:44:47 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
|
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
|
|
|
** Contact: http://www.qt-project.org/legal
|
|
|
|
**
|
|
|
|
** This file is part of the examples of the Qt Toolkit.
|
|
|
|
**
|
|
|
|
** $QT_BEGIN_LICENSE:BSD$
|
|
|
|
** You may use this file under the terms of the BSD license as follows:
|
|
|
|
**
|
|
|
|
** "Redistribution and use in source and binary forms, with or without
|
|
|
|
** modification, are permitted provided that the following conditions are
|
|
|
|
** met:
|
|
|
|
** * Redistributions of source code must retain the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer.
|
|
|
|
** * Redistributions in binary form must reproduce the above copyright
|
|
|
|
** notice, this list of conditions and the following disclaimer in
|
|
|
|
** the documentation and/or other materials provided with the
|
|
|
|
** distribution.
|
|
|
|
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
|
|
|
|
** of its contributors may be used to endorse or promote products derived
|
|
|
|
** from this software without specific prior written permission.
|
|
|
|
**
|
|
|
|
**
|
|
|
|
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
|
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
2013-03-07 09:20:19 +00:00
|
|
|
#include <QtCore/QThread>
|
|
|
|
|
2013-02-27 07:44:47 +00:00
|
|
|
#include <QGuiApplication>
|
|
|
|
|
|
|
|
#include <QtQuick/QQuickView>
|
|
|
|
|
|
|
|
#include "threadrenderer.h"
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
QGuiApplication app(argc, argv);
|
|
|
|
|
|
|
|
qmlRegisterType<ThreadRenderer>("SceneGraphRendering", 1, 0, "Renderer");
|
2013-03-07 09:20:19 +00:00
|
|
|
int execReturn = 0;
|
|
|
|
|
|
|
|
{
|
|
|
|
QQuickView view;
|
|
|
|
|
|
|
|
// Rendering in a thread introduces a slightly more complicated cleanup
|
|
|
|
// so we ensure that no cleanup of graphics resources happen until the
|
|
|
|
// application is shutting down.
|
|
|
|
view.setPersistentOpenGLContext(true);
|
|
|
|
view.setPersistentSceneGraph(true);
|
|
|
|
|
|
|
|
view.setResizeMode(QQuickView::SizeRootObjectToView);
|
|
|
|
view.setSource(QUrl("qrc:///scenegraph/textureinsgnode/main.qml"));
|
|
|
|
view.show();
|
|
|
|
|
|
|
|
execReturn = app.exec();
|
|
|
|
}
|
2013-02-27 07:44:47 +00:00
|
|
|
|
2013-03-07 09:20:19 +00:00
|
|
|
// As the render threads make use of our QGuiApplication object
|
|
|
|
// to clean up gracefully, wait for them to finish before
|
|
|
|
// QGuiApp is taken off the heap.
|
|
|
|
foreach (QThread *t, ThreadRenderer::threads) {
|
|
|
|
t->wait();
|
|
|
|
delete t;
|
|
|
|
}
|
2013-02-27 07:44:47 +00:00
|
|
|
|
2013-03-07 09:20:19 +00:00
|
|
|
return execReturn;
|
2013-02-27 07:44:47 +00:00
|
|
|
}
|