aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/scenegraph
diff options
context:
space:
mode:
Diffstat (limited to 'examples/quick/scenegraph')
-rw-r--r--examples/quick/scenegraph/customgeometry/beziercurve.cpp6
-rw-r--r--examples/quick/scenegraph/graph/noisynode.cpp3
-rw-r--r--examples/quick/scenegraph/graph/shaders/line.fsh2
-rw-r--r--examples/quick/scenegraph/graph/shaders/noisy.fsh2
-rw-r--r--examples/quick/scenegraph/rendernode/main.cpp16
-rw-r--r--examples/quick/scenegraph/rendernode/softwarerenderer.cpp7
-rw-r--r--examples/quick/scenegraph/sgengine/window.cpp11
-rw-r--r--examples/quick/scenegraph/shared/logorenderer.cpp4
-rw-r--r--examples/quick/scenegraph/textureinsgnode/main.qml2
-rw-r--r--examples/quick/scenegraph/textureinthread/main.qml2
-rw-r--r--examples/quick/scenegraph/twotextureproviders/main.qml2
11 files changed, 37 insertions, 20 deletions
diff --git a/examples/quick/scenegraph/customgeometry/beziercurve.cpp b/examples/quick/scenegraph/customgeometry/beziercurve.cpp
index ca3c6f524b..750ff6aa3b 100644
--- a/examples/quick/scenegraph/customgeometry/beziercurve.cpp
+++ b/examples/quick/scenegraph/customgeometry/beziercurve.cpp
@@ -152,7 +152,7 @@ QSGNode *BezierCurve::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
//! [7]
//! [8]
- QRectF bounds = boundingRect();
+ QSizeF itemSize = size();
QSGGeometry::Point2D *vertices = geometry->vertexDataAsPoint2D();
for (int i = 0; i < m_segmentCount; ++i) {
qreal t = i / qreal(m_segmentCount - 1);
@@ -163,8 +163,8 @@ QSGNode *BezierCurve::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
+ 3 * invt * t * t * m_p3
+ t * t * t * m_p4;
- float x = bounds.x() + pos.x() * bounds.width();
- float y = bounds.y() + pos.y() * bounds.height();
+ float x = pos.x() * itemSize.width();
+ float y = pos.y() * itemSize.height();
vertices[i].set(x, y);
}
diff --git a/examples/quick/scenegraph/graph/noisynode.cpp b/examples/quick/scenegraph/graph/noisynode.cpp
index 762a47ec1f..6e79bb247f 100644
--- a/examples/quick/scenegraph/graph/noisynode.cpp
+++ b/examples/quick/scenegraph/graph/noisynode.cpp
@@ -50,6 +50,7 @@
#include "noisynode.h"
+#include <QtCore/QRandomGenerator>
#include <QtQuick/QSGSimpleMaterialShader>
#include <QtQuick/QSGTexture>
#include <QtQuick/QQuickWindow>
@@ -113,7 +114,7 @@ NoisyNode::NoisyNode(QQuickWindow *window)
QImage image(NOISE_SIZE, NOISE_SIZE, QImage::Format_RGB32);
uint *data = (uint *) image.bits();
for (int i=0; i<NOISE_SIZE * NOISE_SIZE; ++i) {
- uint g = rand() & 0xff;
+ uint g = QRandomGenerator::global()->bounded(0xff);
data[i] = 0xff000000 | (g << 16) | (g << 8) | g;
}
diff --git a/examples/quick/scenegraph/graph/shaders/line.fsh b/examples/quick/scenegraph/graph/shaders/line.fsh
index 378cc1084f..77e05a2d15 100644
--- a/examples/quick/scenegraph/graph/shaders/line.fsh
+++ b/examples/quick/scenegraph/graph/shaders/line.fsh
@@ -54,7 +54,7 @@ uniform lowp float spread;
varying lowp float vT;
-#define PI 3.14159265359
+#define PI 3.14159265358979323846
void main(void)
{
diff --git a/examples/quick/scenegraph/graph/shaders/noisy.fsh b/examples/quick/scenegraph/graph/shaders/noisy.fsh
index 2796f24bd8..14ea675360 100644
--- a/examples/quick/scenegraph/graph/shaders/noisy.fsh
+++ b/examples/quick/scenegraph/graph/shaders/noisy.fsh
@@ -55,7 +55,7 @@ uniform lowp vec4 color;
varying highp vec2 vTexCoord;
varying lowp vec2 vShadeCoord;
-#define PI 3.14159265359
+#define PI 3.14159265358979323846
void main()
{
diff --git a/examples/quick/scenegraph/rendernode/main.cpp b/examples/quick/scenegraph/rendernode/main.cpp
index d6c1b000c3..21419abfc9 100644
--- a/examples/quick/scenegraph/rendernode/main.cpp
+++ b/examples/quick/scenegraph/rendernode/main.cpp
@@ -48,6 +48,8 @@
**
****************************************************************************/
+#include <QCommandLineParser>
+#include <QCommandLineOption>
#include <QGuiApplication>
#include <QQuickView>
#include "customrenderitem.h"
@@ -60,7 +62,19 @@ int main(int argc, char **argv)
QQuickView view;
- if (QCoreApplication::arguments().contains(QStringLiteral("--multisample"))) {
+ QCoreApplication::setApplicationName("Qt Scene Graph Render Node Example");
+ QCoreApplication::setOrganizationName("QtProject");
+ QCoreApplication::setApplicationVersion(QT_VERSION_STR);
+ QCommandLineParser parser;
+ parser.setApplicationDescription(QCoreApplication::applicationName());
+ parser.addHelpOption();
+ parser.addVersionOption();
+ QCommandLineOption multipleSampleOption("multisample", "Multisampling");
+ parser.addOption(multipleSampleOption);
+
+ parser.process(app);
+
+ if (parser.isSet(multipleSampleOption)) {
QSurfaceFormat fmt;
fmt.setSamples(4);
view.setFormat(fmt);
diff --git a/examples/quick/scenegraph/rendernode/softwarerenderer.cpp b/examples/quick/scenegraph/rendernode/softwarerenderer.cpp
index f1c496e23a..b6f7ffa577 100644
--- a/examples/quick/scenegraph/rendernode/softwarerenderer.cpp
+++ b/examples/quick/scenegraph/rendernode/softwarerenderer.cpp
@@ -74,11 +74,12 @@ void SoftwareRenderNode::render(const RenderState *renderState)
QPainter *p = static_cast<QPainter *>(rif->getResource(m_item->window(), QSGRendererInterface::PainterResource));
Q_ASSERT(p);
- p->setTransform(matrix()->toTransform());
- p->setOpacity(inheritedOpacity());
const QRegion *clipRegion = renderState->clipRegion();
if (clipRegion && !clipRegion->isEmpty())
- p->setClipRegion(*clipRegion, Qt::IntersectClip);
+ p->setClipRegion(*clipRegion, Qt::ReplaceClip); // must be done before setTransform
+
+ p->setTransform(matrix()->toTransform());
+ p->setOpacity(inheritedOpacity());
const QPointF p0(m_item->width() - 1, m_item->height() - 1);
const QPointF p1(0, 0);
diff --git a/examples/quick/scenegraph/sgengine/window.cpp b/examples/quick/scenegraph/sgengine/window.cpp
index 96b730ebfc..6f22510a81 100644
--- a/examples/quick/scenegraph/sgengine/window.cpp
+++ b/examples/quick/scenegraph/sgengine/window.cpp
@@ -58,6 +58,7 @@
#include <QScreen>
#include <QVariantAnimation>
#include <QOpenGLFunctions>
+#include <QRandomGenerator>
class Item {
public:
@@ -71,9 +72,9 @@ public:
transformNode->appendChildNode(textureNode);
parentNode->appendChildNode(transformNode);
- int duration = qrand() / float(RAND_MAX) * 400 + 800;
- rotAnimation.setStartValue(qrand() / float(RAND_MAX) * 720 - 180);
- rotAnimation.setEndValue(qrand() / float(RAND_MAX) * 720 - 180);
+ int duration = QRandomGenerator::global()->generateDouble() * 400 + 800;
+ rotAnimation.setStartValue(QRandomGenerator::global()->generateDouble() * 720 - 180);
+ rotAnimation.setEndValue(QRandomGenerator::global()->generateDouble() * 720 - 180);
rotAnimation.setDuration(duration);
rotAnimation.start();
@@ -181,8 +182,8 @@ void Window::addItems()
QSGTexture *textures[] = { m_smileTexture.data(), m_qtTexture.data() };
for (int i = 0; i < 50; ++i) {
QSGTexture *tex = textures[i%2];
- QPointF fromPos(-tex->textureSize().width(), qrand() / float(RAND_MAX) * (height() - tex->textureSize().height()));
- QPointF toPos(width(), qrand() / float(RAND_MAX) * height() * 1.5 - height() * 0.25);
+ QPointF fromPos(-tex->textureSize().width(), QRandomGenerator::global()->generateDouble() * (height() - tex->textureSize().height()));
+ QPointF toPos(width(), QRandomGenerator::global()->generateDouble() * height() * 1.5 - height() * 0.25);
m_items.append(QSharedPointer<Item>::create(m_sgRootNode.data(), tex, fromPos, toPos));
}
update();
diff --git a/examples/quick/scenegraph/shared/logorenderer.cpp b/examples/quick/scenegraph/shared/logorenderer.cpp
index 8dea8d9d0c..0c34fb4402 100644
--- a/examples/quick/scenegraph/shared/logorenderer.cpp
+++ b/examples/quick/scenegraph/shared/logorenderer.cpp
@@ -51,7 +51,7 @@
#include "logorenderer.h"
#include <QPainter>
#include <QPaintEngine>
-#include <math.h>
+#include <qmath.h>
LogoRenderer::LogoRenderer()
{
@@ -176,7 +176,7 @@ void LogoRenderer::createGeometry()
extrude(x4, y4, y4, x4);
extrude(y4, x4, y3, x3);
- const qreal Pi = 3.14159f;
+ const qreal Pi = M_PI;
const int NumSectors = 100;
for (int i = 0; i < NumSectors; ++i) {
diff --git a/examples/quick/scenegraph/textureinsgnode/main.qml b/examples/quick/scenegraph/textureinsgnode/main.qml
index c8509707ae..92fa99e847 100644
--- a/examples/quick/scenegraph/textureinsgnode/main.qml
+++ b/examples/quick/scenegraph/textureinsgnode/main.qml
@@ -74,7 +74,7 @@ Item {
uniform highp vec2 pixelSize;
varying highp vec2 qt_TexCoord0;
void main() {
- highp vec2 tc = sign(sin(3.14152 * qt_TexCoord0 * pixelSize));
+ highp vec2 tc = sign(sin(3.14159265358979323846 * qt_TexCoord0 * pixelSize));
if (tc.x != tc.y)
gl_FragColor = color1;
else
diff --git a/examples/quick/scenegraph/textureinthread/main.qml b/examples/quick/scenegraph/textureinthread/main.qml
index f20d318807..eefee92f15 100644
--- a/examples/quick/scenegraph/textureinthread/main.qml
+++ b/examples/quick/scenegraph/textureinthread/main.qml
@@ -74,7 +74,7 @@ Item {
uniform highp vec2 pixelSize;
varying highp vec2 qt_TexCoord0;
void main() {
- highp vec2 tc = sign(sin(3.14152 * qt_TexCoord0 * pixelSize));
+ highp vec2 tc = sign(sin(3.14159265358979323846 * qt_TexCoord0 * pixelSize));
if (tc.x != tc.y)
gl_FragColor = color1;
else
diff --git a/examples/quick/scenegraph/twotextureproviders/main.qml b/examples/quick/scenegraph/twotextureproviders/main.qml
index 641034104c..296df766a1 100644
--- a/examples/quick/scenegraph/twotextureproviders/main.qml
+++ b/examples/quick/scenegraph/twotextureproviders/main.qml
@@ -71,7 +71,7 @@ Item {
uniform highp vec2 pixelSize;
varying highp vec2 qt_TexCoord0;
void main() {
- highp vec2 tc = sign(sin(3.14152 * qt_TexCoord0 * pixelSize));
+ highp vec2 tc = sign(sin(3.14159265358979323846 * qt_TexCoord0 * pixelSize));
if (tc.x != tc.y)
gl_FragColor = color1;
else