aboutsummaryrefslogtreecommitdiffstats
path: root/examples/quick/scenegraph/customgeometry
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar.sletta@digia.com>2012-12-12 20:11:12 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-01-07 10:44:02 +0100
commit077ad5f30446f6b3ccc38cb7f05897566f8e5eb7 (patch)
treedec3a47d3c2589b91299c2cbf975de041ed3b8bd /examples/quick/scenegraph/customgeometry
parentb58eb5239452d282b7209784274714b25f530a3c (diff)
Documentation for scene graph examples.
Change-Id: Idb39fc0b6d5e538b90ae8a0b98d9f4d77e1fb617 Reviewed-by: Yoann Lopes <yoann.lopes@digia.com>
Diffstat (limited to 'examples/quick/scenegraph/customgeometry')
-rw-r--r--examples/quick/scenegraph/customgeometry/doc/images/custom-geometry-example.pngbin0 -> 18006 bytes
-rw-r--r--examples/quick/scenegraph/customgeometry/doc/src/customgeometry.qdoc33
-rw-r--r--examples/quick/scenegraph/customgeometry/main.cpp3
3 files changed, 23 insertions, 13 deletions
diff --git a/examples/quick/scenegraph/customgeometry/doc/images/custom-geometry-example.png b/examples/quick/scenegraph/customgeometry/doc/images/custom-geometry-example.png
new file mode 100644
index 0000000000..4ed20d3485
--- /dev/null
+++ b/examples/quick/scenegraph/customgeometry/doc/images/custom-geometry-example.png
Binary files differ
diff --git a/examples/quick/scenegraph/customgeometry/doc/src/customgeometry.qdoc b/examples/quick/scenegraph/customgeometry/doc/src/customgeometry.qdoc
index c226634823..7127fd0dc4 100644
--- a/examples/quick/scenegraph/customgeometry/doc/src/customgeometry.qdoc
+++ b/examples/quick/scenegraph/customgeometry/doc/src/customgeometry.qdoc
@@ -28,7 +28,8 @@
/*!
\example quick/scenegraph/customgeometry
\title Custom Geometry Example
- \ingroup examples
+ \ingroup qtquickexamples
+ \brief Shows how to implement a custom geometry in the Qt Quick Scene Graph.
\brief The custom geometry example shows how to create a QQuickItem which
uses the scene graph API to build a custom geometry for the scene
@@ -58,11 +59,11 @@
QQuickItem::updatePaintNode() which all items with custom scene
graph logic must implement.
- \e { The scene graph will on many hardware configurations be
+ \note The scene graph will on many hardware configurations be
rendering on a separate thread. It is therefore crucial that
- interaction with the scene graph happens in a controlled
- manner, first and foremost through the \l
- QQuickItem::updatePaintNode() function. }
+ interaction with the scene graph happens in a controlled manner,
+ first and foremost through the \l QQuickItem::updatePaintNode()
+ function.
\section1 BezierCurve Implementation
@@ -122,17 +123,17 @@
set which has two floats, one for x coordinates and one for y
coordinates. The second argument is the vertex count.
- \e {Custom attribute sets can also created, but that is not
- covered in this example}.
+ Custom attribute sets can also created, but that is not
+ covered in this example.
Since we do not have any special needs for memory managing the
geometry, we specify that the QSGGeometryNode should own the
geometry.
- \e {To minimize allocations, reduce memory fragmentation and
+ To minimize allocations, reduce memory fragmentation and
improve performance, it would also be possible to make the
geometry a member of a QSGGeometryNode subclass, in which case, we
- would not have set the QSGGeometryNode::OwnsGeometry flag}.
+ would not have set the QSGGeometryNode::OwnsGeometry flag.
\snippet quick/scenegraph/customgeometry/beziercurve.cpp 6
@@ -174,26 +175,32 @@
BezierCurve and make it part of the \c {CustomGeometry 1.0}
module.
+ As the bezier curve is drawn using GL_LINE_STRIP, we specify that
+ the view should be multisampled to get antialiasing. This is not
+ required, but it will make the item look a bit nicer on hardware
+ that supports it. Multisampling is not enabled by default because
+ it often results in higher memory usage.
+
\section1 Using the Item
- \snippet quick/scenegraph/customgeometry/LineTester.qml 1
+ \snippet quick/scenegraph/customgeometry/main.qml 1
Our .qml file imports the \c {QtQuick 2.0} module to get the
standard elements and also our own \c {CustomGeometry 1.0} module
which contains our newly created BezierCurve element.
- \snippet quick/scenegraph/customgeometry/LineTester.qml 2
+ \snippet quick/scenegraph/customgeometry/main.qml 2
Then we create the our root item and an instance of the
BezierCurve which we anchor to fill the root.
- \snippet quick/scenegraph/customgeometry/LineTester.qml 3
+ \snippet quick/scenegraph/customgeometry/main.qml 3
To make the example a bit more interesting we add an animation to
change the two control points in the curve. The end points stay
unchanged.
- \snippet quick/scenegraph/customgeometry/LineTester.qml 4
+ \snippet quick/scenegraph/customgeometry/main.qml 4
Finally we overlay a short text outlining what the example shows.
diff --git a/examples/quick/scenegraph/customgeometry/main.cpp b/examples/quick/scenegraph/customgeometry/main.cpp
index ea699c1c36..f2ec27d229 100644
--- a/examples/quick/scenegraph/customgeometry/main.cpp
+++ b/examples/quick/scenegraph/customgeometry/main.cpp
@@ -52,6 +52,9 @@ int main(int argc, char **argv)
qmlRegisterType<BezierCurve>("CustomGeometry", 1, 0, "BezierCurve");
QQuickView view;
+ QSurfaceFormat format;
+ format.setSamples(16);
+ view.setFormat(format);
view.setSource(QUrl("qrc:///scenegraph/customgeometry/main.qml"));
view.show();