Skip to content

Commit

Permalink
Docs for vertex and flat color materials
Browse files Browse the repository at this point in the history
  • Loading branch information
Gunnar Sletta committed May 9, 2011
1 parent b7e0c07 commit aba3870
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
52 changes: 52 additions & 0 deletions src/declarative/scenegraph/util/qsgflatcolormaterial.cpp
Expand Up @@ -116,22 +116,74 @@ 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;
setFlag(Blending, m_color.alpha() != 0xff);
}



/*!
\internal
*/

QSGMaterialType *QSGFlatColorMaterial::type() const
{
return &FlatColorMaterialShader::type;
}



/*!
\internal
*/

QSGMaterialShader *QSGFlatColorMaterial::createShader() const
{
return new FlatColorMaterialShader;
Expand Down
53 changes: 53 additions & 0 deletions src/declarative/scenegraph/util/qsgvertexcolormaterial.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit aba3870

Please sign in to comment.