2011-11-16 14:39:45 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2016-01-19 11:04:37 +00:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-11-16 14:39:45 +00:00
|
|
|
**
|
|
|
|
** This file is part of the demonstration applications of the Qt Toolkit.
|
|
|
|
**
|
2016-01-19 11:04:37 +00:00
|
|
|
** $QT_BEGIN_LICENSE:BSD$
|
2012-09-20 05:21:40 +00:00
|
|
|
** 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
|
2015-01-28 11:55:39 +00:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
2016-01-19 11:04:37 +00:00
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
|
|
|
**
|
|
|
|
** BSD License Usage
|
|
|
|
** Alternatively, 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 The Qt Company Ltd 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."
|
2011-11-16 14:39:45 +00:00
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef SQUIRCLE_H
|
|
|
|
#define SQUIRCLE_H
|
|
|
|
|
Say hello to QtQuick module
This change moves the QtQuick 2 types and C++ API (including
SceneGraph) to a new module (AKA library), QtQuick.
99% of this change is moving files from src/declarative to
src/quick, and from tests/auto/declarative to
tests/auto/qtquick2.
The loading of QtQuick 2 ("import QtQuick 2.0") is now delegated to
a plugin, src/imports/qtquick2, just like it's done for QtQuick 1.
All tools, examples, and tests that use QtQuick C++ API have gotten
"QT += quick" or "QT += quick-private" added to their .pro file.
A few additional internal QtDeclarative classes had to be exported
(via Q_DECLARATIVE_PRIVATE_EXPORT) since they're needed by the
QtQuick 2 implementation.
The old header locations (e.g. QtDeclarative/qquickitem.h) will
still be supported for some time, but will produce compile-time
warnings. (To avoid the QtQuick implementation using the
compatibility headers (since QtDeclarative's includepath comes
first), a few include statements were modified, e.g. from
"#include <qsgnode.h>" to "#include <QtQuick/qsgnode.h>".)
There's a change in qtbase that automatically adds QtQuick to the
module list if QtDeclarative is used. Together with the compatibility
headers, this should help reduce the migration pain for existing
projects.
In theory, simply getting an existing QtDeclarative-based project
to compile and link shouldn't require any changes for now -- but
porting to the new scheme is of course recommended, and will
eventually become mandatory.
Task-number: QTBUG-22889
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Change-Id: Ia52be9373172ba2f37e7623231ecb060316c96a7
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
Reviewed-by: Sergio Ahumada <sergio.ahumada@nokia.com>
2011-11-23 14:14:07 +00:00
|
|
|
#include <QtQuick/QQuickItem>
|
2011-11-16 14:39:45 +00:00
|
|
|
#include <QtGui/QOpenGLShaderProgram>
|
2014-06-26 13:08:47 +00:00
|
|
|
#include <QtGui/QOpenGLFunctions>
|
2011-11-16 14:39:45 +00:00
|
|
|
|
2014-06-13 11:59:57 +00:00
|
|
|
|
|
|
|
|
2012-07-30 09:09:23 +00:00
|
|
|
//! [1]
|
2014-07-02 07:58:13 +00:00
|
|
|
class SquircleRenderer : public QObject, protected QOpenGLFunctions
|
2011-11-16 14:39:45 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
2014-06-13 11:59:57 +00:00
|
|
|
public:
|
|
|
|
SquircleRenderer() : m_t(0), m_program(0) { }
|
|
|
|
~SquircleRenderer();
|
2011-11-16 14:39:45 +00:00
|
|
|
|
2014-06-13 11:59:57 +00:00
|
|
|
void setT(qreal t) { m_t = t; }
|
|
|
|
void setViewportSize(const QSize &size) { m_viewportSize = size; }
|
2015-03-31 14:14:14 +00:00
|
|
|
void setWindow(QQuickWindow *window) { m_window = window; }
|
2014-06-13 11:59:57 +00:00
|
|
|
|
|
|
|
public slots:
|
2019-06-25 14:37:58 +00:00
|
|
|
void init();
|
2014-06-13 11:59:57 +00:00
|
|
|
void paint();
|
|
|
|
|
|
|
|
private:
|
|
|
|
QSize m_viewportSize;
|
|
|
|
qreal m_t;
|
|
|
|
QOpenGLShaderProgram *m_program;
|
2015-03-31 14:14:14 +00:00
|
|
|
QQuickWindow *m_window;
|
2014-06-13 11:59:57 +00:00
|
|
|
};
|
2012-07-30 09:09:23 +00:00
|
|
|
//! [1]
|
2014-06-13 11:59:57 +00:00
|
|
|
|
|
|
|
//! [2]
|
2011-11-16 14:39:45 +00:00
|
|
|
class Squircle : public QQuickItem
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(qreal t READ t WRITE setT NOTIFY tChanged)
|
2019-08-21 16:34:21 +00:00
|
|
|
QML_ELEMENT
|
2011-11-16 14:39:45 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
Squircle();
|
|
|
|
|
|
|
|
qreal t() const { return m_t; }
|
2012-07-30 09:09:23 +00:00
|
|
|
void setT(qreal t);
|
2011-11-16 14:39:45 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void tChanged();
|
|
|
|
|
|
|
|
public slots:
|
2012-12-12 19:11:12 +00:00
|
|
|
void sync();
|
2014-06-13 11:59:57 +00:00
|
|
|
void cleanup();
|
2011-11-16 14:39:45 +00:00
|
|
|
|
2013-04-25 09:16:40 +00:00
|
|
|
private slots:
|
|
|
|
void handleWindowChanged(QQuickWindow *win);
|
|
|
|
|
2011-11-16 14:39:45 +00:00
|
|
|
private:
|
Add the graphics api independent scenegraph port
Opt in via environment variables:
QSG_RHI=1 -> enable using QRhi instead of GL
QSG_RHI_BACKEND -> set to vulkan, metal, d3d11, gl to override the default
(the default is d3d11 on Windows, metal on Mac, gl elsewhere)
Or force a given rhi backend via the existing
QQuickWindow::setSceneGraphBackend().
Otherwise the default behavior is the same as before, the rhi code path
is never active by default.
-no-opengl builds are supported in the sense that they work and default
to the software backend. However, the rhi code path cannot currently be
used in such builds, even though QRhi from qtbase is fully functional
with Vulkan, D3D, or Metal even when qtbase was configured with
-no-opengl. This cannot be utilized by Quick atm due to OpenGL usage
being all over the place in the sources corresponding to the default
backend, and those host the rhi code path as well. This will be cleaned up
hopefully in Qt 6, with the removal all direct OpenGL usage.
Other env.vars.:
QSG_RHI_DEBUG_LAYER=1 -> enable D3D debug or Vulkan validation layer
(assuming the system is set up for this)
QSG_RHI_SHADEREFFECT_DEBUG=1 -> print stuff from ShaderEffect
QSG_SAMPLES=1,2,4,... -> MSAA sample count (but QSurfaceFormat works too)
QT_D3D_ADAPTER_INDEX=0,1,... -> D3D adapter index
QT_VK_PHYSICAL_DEVICE_INDEX=0,1,... -> Vulkan physical device index
QSG_RHI_UINT32_INDEX=1 -> always use uint index data (both
merged/unmerged, convert when needed - with some rhi backends this is
implicit)
QSG_RENDER_LOOP -> to override the render loop as usual. The default
with RHI is threaded for Metal, threaded for Vulkan on Windows, basic
for Vulkan on Linux and Android (to be checked later), while the existing
rules apply for OpenGL.
Not supported when running with QRhi:
- particles
- compressed atlases (though this is transparent to the apps)
- QSGRenderNode
- QQuickRenderControl
- QQuickFramebufferObject
- certain QQuickWindow functionality that depends directly on OpenGL
- anisotropic filtering for textures
- native text may lack some gamma correction
- QSGEngine applicability unclear
- some QML profiler logs may be incorrect or irrelevant
Change-Id: I7822e99ad79e342e4166275da6e9e66498d76521
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2019-04-23 07:40:59 +00:00
|
|
|
void releaseResources() override;
|
|
|
|
|
2011-11-16 14:39:45 +00:00
|
|
|
qreal m_t;
|
2014-06-13 11:59:57 +00:00
|
|
|
SquircleRenderer *m_renderer;
|
2011-11-16 14:39:45 +00:00
|
|
|
};
|
2014-06-13 11:59:57 +00:00
|
|
|
//! [2]
|
2011-11-16 14:39:45 +00:00
|
|
|
|
|
|
|
#endif // SQUIRCLE_H
|