Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QSGMaterial Class

The QSGMaterial class encapsulates rendering state for a shader program. More...

 #include <QSGMaterial>

Inherited by: QSGFlatColorMaterial, QSGOpaqueTextureMaterial, QSGSimpleMaterial, and QSGVertexColorMaterial.

Public Types

enum Flag { Blending, RequiresDeterminant, RequiresFullMatrix }
flags Flags

Public Functions

QSGMaterial()
virtual ~QSGMaterial()
virtual int compare(const QSGMaterial * other) const
virtual QSGMaterialShader * createShader() const = 0
QSGMaterial::Flags flags() const
void setFlag(Flags flags, bool on = true)
virtual QSGMaterialType * type() const = 0

Detailed Description

The QSGMaterial class encapsulates rendering state for a shader program.

The QSGMaterial API is very low-level. A more convenient API, which provides almost all the same features, is available through QSGSimpleMaterialShader.

The QSGMaterial and QSGMaterialShader subclasses form a tight relationship. For one scene graph (including nested graphs), there is one unique QSGMaterialShader instance which encapsulates the QOpenGLShaderProgram the scene graph uses to render that material, such as a shader to flat coloring of geometry. Each QSGGeometryNode can have a unique QSGMaterial containing the how the shader should be configured when drawing that node, such as the actual color to used to render the geometry.

The QSGMaterial has two virtual functions that both need to be implemented. The function type() should return a unique instance for all instances of a specific subclass. The createShader() function should return a new instance of QSGMaterialShader, specific to the subclass of QSGMaterial.

A minimal QSGMaterial implementation could look like this:

 class Material : public QSGMaterial
 {
 public:
     QSGMaterialType *type() const { static QSGMaterialType type; return &type; }
     QSGMaterialShader *createShader() const { return new Shader; }
 };

Warning: Instances of QSGMaterial belongs to the Scene Graph rendering thread, and cannot be used from the GUI thread.

Member Type Documentation

enum QSGMaterial::Flag
flags QSGMaterial::Flags

ConstantValueDescription
QSGMaterial::Blending0x0001Set this flag to true if the material requires GL_BLEND to be enabled during rendering.
QSGMaterial::RequiresDeterminant0x0002Set this flag to true if the material relies on the determinant of the matrix of the geometry nodes for rendering.
QSGMaterial::RequiresFullMatrix0x0004 | RequiresDeterminantSet this flag to true if the material relies on the full matrix of the geometry nodes for rendering.

The Flags type is a typedef for QFlags<Flag>. It stores an OR combination of Flag values.

Member Function Documentation

QSGMaterial::QSGMaterial()

QSGMaterial::~QSGMaterial() [virtual]

int QSGMaterial::compare(const QSGMaterial * other) const [virtual]

Compares this material to other and returns 0 if they are equal; -1 if this material should sort before other and 1 if other should sort before.

The scene graph can reorder geometry nodes to minimize state changes. The compare function is called during the sorting process so that the materials can be sorted to minimize state changes in each call to QSGMaterialShader::updateState().

The this pointer and other is guaranteed to have the same type().

QSGMaterialShader * QSGMaterial::createShader() const [pure virtual]

This function returns a new instance of a the QSGMaterialShader implementatation used to render geometry for a specifc implementation of QSGMaterial.

The function will be called only once for each material type that exists in the scene graph and will be cached internally.

QSGMaterial::Flags QSGMaterial::flags() const

void QSGMaterial::setFlag(Flags flags, bool on = true)

Sets the flags flags on this material if on is true; otherwise clears the attribute.

QSGMaterialType * QSGMaterial::type() const [pure virtual]

This function is called by the scene graph to return a unique instance per subclass.

Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. Qt 5.0-snapshot
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD.
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP !
 
 
 
 
Partenaires

Hébergement Web