Detailed Description
The QGLRenderOrder class represents an order of a scene node during rendering.
The QGLRenderOrder class works with the QGLRenderSequencer to optimize the rendering order of scene nodes.
The class encapsulates the ordering with which QGLSceneNodes appear in the rendering of a scene. Every scene node that has the same rendering properties maps to the same QGLRenderOrder.
QGLRenderOrder instances are based on a scene node, and the path through the scene graph by which the node was reached. This is necessary since the same node may appear with different rendering properties in multiple different places in the rendering graph.
For example a node holding a model of a pawn chess piece may appear in several different places on a board, some with a white material and some with a black material.
To capture this concept QGLRenderOrder instances are constructed from a pointer to a QGLSceneNode, and a QGLRenderState instance.
A render order then calculates the effective values of its various attributes based on both the node, and the state.
Custom render orders may be created by sub-classing QGLRenderOrderComparator and reimplementing the following methods:
By default all nodes which have the same effect type are rendered together, and then within that, those nodes which have the same material are rendered together.
Member Function Documentation
QGLRenderOrder::QGLRenderOrder(const QGLSceneNode * node = 0, const QGLRenderState & state = QGLRenderState())
Creates a new QGLRenderOrder instance that encapsulates the order in this render pass represented by the given node and state. The node defaults to NULL, and the state defaults to a default constructed invalid QGLRenderState.
QGLRenderOrder::~QGLRenderOrder()
Destroys this QGLRenderOrder and recovers any resources.
uint QGLRenderOrder::effectHash() const
Returns a hash value representing the effect set onto the node for this render order.
QGLMaterial * QGLRenderOrder::effectiveBackMaterial() const
Returns the effective back material of the node set for this render order, taking into account any effect inherited from parent nodes as specified by the render state().
See also state() and effectiveMaterial().
bool QGLRenderOrder::effectiveHasEffect() const
Returns the effective value of whether an effect is set on the node set for this render order, taking into account any effect inherited from parent nodes as specified by the render state().
See also state().
QGLMaterial * QGLRenderOrder::effectiveMaterial() const
Returns the effective material of the node set for this render order, taking into account any effect inherited from parent nodes as specified by the render state().
See also state() and effectiveBackMaterial().
QGL::StandardEffect QGLRenderOrder::effectiveStandardEffect() const
Returns the effective standard effect of the node set for this render order, taking into account any effect inherited from parent nodes as specified by the render state().
See also state() and effectiveHasEffect().
QGLAbstractEffect * QGLRenderOrder::effectiveUserEffect() const
Returns the effective user effect of the node set for this render order, taking into account any effect inherited from parent nodes as specified by the render state().
See also state() and effectiveHasEffect().
bool QGLRenderOrder::isEqual(const QGLRenderOrder & rhs) const
Returns true if this QGLRenderOrder is equal to the rhs, otherwise returns false. Reimplement this function when creating a sub-class of QGLRenderOrder.
See also isLessThan().
bool QGLRenderOrder::isLessThan(const QGLRenderOrder & rhs) const
Returns true if this QGLRenderOrder is less than the rhs, otherwise returns false. Reimplement this function when creating a sub-class of QGLRenderOrder.
The default implementation sorts first by effect, second by material (front then back).
Sorting by material is ordered by pointer comparison.
Sorting by effect is based on the following order, from lowest to highest:
- No effect - hasEffect() == true
- Standard effect - ordered by numerical value, eg QGL::FlatColor < QGL::LitMaterial
- User effect - ordered by pointer comparison
So a node with hasEffect() == false node is less than a node with a custom user effect, for example.
See also isEqual().
bool QGLRenderOrder::isValid() const
Returns true if this is a valid QGLRenderOrder, that is it was initialized with a non-null QGLSceneNode.
const QGLSceneNode * QGLRenderOrder::node() const
Returns a pointer to the scene node for which the render order is held by this QGLRenderOrder instance. This is simply the value passed to the constructor.
void QGLRenderOrder::setState(const QGLRenderState & state)
Sets the state for this order.
See also state().
QGLRenderState QGLRenderOrder::state() const
Returns a pointer to the render state for this order. This is simply the value passed to the constructor.
See also setState().
bool QGLRenderOrder::operator!=(const QGLRenderOrder & rhs) const
Returns true if this QGLRenderOrder is not equal to the rhs, otherwise returns false. This function simply returns !isEqual(rhs).
bool QGLRenderOrder::operator<(const QGLRenderOrder & rhs) const
Returns true if this QGLRenderOrder is less than to the rhs, otherwise returns false. This function simply returns isLessThan(rhs).
bool QGLRenderOrder::operator==(const QGLRenderOrder & rhs) const
Returns true if this QGLRenderOrder is equal to the rhs, otherwise returns false. This function simply returns isEqual(rhs).