From aba38703916f6e6a3808cd1531b4810c631f15a3 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 9 May 2011 11:54:10 +0200 Subject: Docs for vertex and flat color materials --- .../scenegraph/util/qsgflatcolormaterial.cpp | 52 +++++++++++++++++++++ .../scenegraph/util/qsgvertexcolormaterial.cpp | 53 ++++++++++++++++++++++ 2 files changed, 105 insertions(+) (limited to 'src') diff --git a/src/declarative/scenegraph/util/qsgflatcolormaterial.cpp b/src/declarative/scenegraph/util/qsgflatcolormaterial.cpp index e348655e6b..ed3d96fee5 100644 --- a/src/declarative/scenegraph/util/qsgflatcolormaterial.cpp +++ b/src/declarative/scenegraph/util/qsgflatcolormaterial.cpp @@ -116,10 +116,51 @@ const char *FlatColorMaterialShader::fragmentShader() const { } + +/*! + \class QSGFlatColorMaterial + \brief The QSGFlatColorMaterial provides a convenient way of rendering + solid colored geometry in the scene graph. + + The flat color material will fill every pixel in a geometry using + a solid color. The color can contain transparency. + + The geometry to be rendered with a flat color material requires + vertices in attribute location 0 in the QSGGeometry object to render + correctly. The QSGGeometry::defaultAttributes_Point2D() returns an attribute + set compatible with this material. + + The flat color material respects both current opacity and current matrix + when updating it's rendering state. + */ + + +/*! + Constructs a new flat color material. + + The default color is white. + */ + QSGFlatColorMaterial::QSGFlatColorMaterial() : m_color(QColor(255, 255, 255)) { } + + +/*! + \fn QColor QSGFlatColorMaterial::color() const + + Returns this flat color material's color. + + The default color is white. + */ + + + +/*! + Sets this flat color material's color to \a color. + */ + void QSGFlatColorMaterial::setColor(const QColor &color) { m_color = color; @@ -127,11 +168,22 @@ void QSGFlatColorMaterial::setColor(const QColor &color) } + +/*! + \internal + */ + QSGMaterialType *QSGFlatColorMaterial::type() const { return &FlatColorMaterialShader::type; } + + +/*! + \internal + */ + QSGMaterialShader *QSGFlatColorMaterial::createShader() const { return new FlatColorMaterialShader; diff --git a/src/declarative/scenegraph/util/qsgvertexcolormaterial.cpp b/src/declarative/scenegraph/util/qsgvertexcolormaterial.cpp index bbd57ea1c2..429251a02a 100644 --- a/src/declarative/scenegraph/util/qsgvertexcolormaterial.cpp +++ b/src/declarative/scenegraph/util/qsgvertexcolormaterial.cpp @@ -107,22 +107,75 @@ const char *QSGVertexColorMaterialShader::fragmentShader() const { } + +/*! + \class QSGVertexColorMaterial + \brief The QSGVertexColorMaterial provides a convenient way of rendering per-vertex + colored geometry in the scene graph. + + The vertex color material will give each vertex in a geometry a color. Pixels between + vertices will be linearly interpolated. The colors can contain transparency. + + The geometry to be rendered with vertex color must have the following layout. Attribute + position 0 must contain vertices. Attribute position 1 must contain colors, a tuple of + 4 values with RGBA layout. Both floats in the range of 0 to 1 and unsigned bytes in + the range 0 to 255 are valid for the color values. The + QSGGeometry::defaultAttributes_ColoredPoint2D() constructs an attribute set + compatible with this material. + + The vertex color material respets both current opacity and current matrix when + updating it's rendering state. + */ + + QSGVertexColorMaterial::QSGVertexColorMaterial(bool opaque) : m_opaque(opaque) { setFlag(Blending, !opaque); } + + +/*! + \fn bool QSGVertexColorMaterial::opaque() const + + Returns if the vertex color material should interpret all colors + as opaque. + */ + + + +/*! + Sets wether the material should interpret all colors in the + geometry as \a opaque. + + This is an optimization hint. Setting opaque to true for geometry that only + contains opaque colors, can lead to better performance. + + */ + void QSGVertexColorMaterial::setOpaque(bool opaque) { setFlag(Blending, !opaque); m_opaque = opaque; } + + +/*! + \internal + */ + QSGMaterialType *QSGVertexColorMaterial::type() const { return &QSGVertexColorMaterialShader::type; } + + +/*! + \internal + */ + QSGMaterialShader *QSGVertexColorMaterial::createShader() const { return new QSGVertexColorMaterialShader; -- cgit v1.2.3