DrawableNode class
#include <nCine/Graphics/DrawableNode.h>
Base class for scene nodes that can be drawn through the render queue.
Extends SceneNode with everything needed to issue a draw: a node area (width and height), an anchor point for its transform, blending state and a RenderCommand. On OnDraw the node updates its render command and submits it to the render queue. Concrete drawables (sprites, particles) derive from this class.
Base classes
- class SceneNode
- Base node of the scene graph transformation hierarchy.
Derived classes
- class BaseSprite
- Base class for textured sprites.
Public types
- enum class BlendingPreset { DISABLED, ALPHA, PREMULTIPLIED_ALPHA, ADDITIVE, MULTIPLY }
- Presets for source and destination blending factors.
- enum class BlendingFactor { ZERO, ONE, SRC_COLOR, ONE_MINUS_SRC_COLOR, DST_COLOR, ONE_MINUS_DST_COLOR, SRC_ALPHA, ONE_MINUS_SRC_ALPHA, DST_ALPHA, ONE_MINUS_DST_ALPHA, CONSTANT_COLOR, ONE_MINUS_CONSTANT_COLOR, CONSTANT_ALPHA, ONE_MINUS_CONSTANT_ALPHA, SRC_ALPHA_SATURATE }
- OpenGL blending factors.
Constructors, destructors, conversion operators
- DrawableNode(SceneNode* parent, float xx, float yy)
- Creates a node as a child of
parentat the relative position (xx,yy). - DrawableNode(SceneNode* parent, Vector2f position)
- Creates a node as a child of
parentat the relative positionposition. - DrawableNode(SceneNode* parent) explicit
- Creates a node as a child of
parent, positioned at the relative origin. - DrawableNode()
- Creates a node with no parent, positioned at the origin.
- ~DrawableNode() override
- DrawableNode(DrawableNode&&)
- DrawableNode(const DrawableNode& other) protected
- Protected copy constructor used to clone objects.
Public functions
- auto operator=(const DrawableNode&) -> DrawableNode& deleted
- auto operator=(DrawableNode&&) -> DrawableNode&
- auto OnDraw(RenderQueue& renderQueue) -> bool override
- Called when the node needs to be drawn, returning
trueif a command was added. - auto width() const -> float virtual
- Returns the width of the node area.
- auto height() const -> float virtual
- Returns the height of the node area.
- auto size() const -> Vector2f
- Returns the size of the node area.
- auto absWidth() const -> float virtual
- Returns the absolute width of the node area.
- auto absHeight() const -> float virtual
- Returns the absolute height of the node area.
- auto absSize() const -> Vector2f
- Returns the absolute size of the node area.
- auto anchorPoint() const -> Vector2f
- Returns the transformation anchor point.
- void setAnchorPoint(float xx, float yy)
- Sets the transformation anchor point.
- void setAnchorPoint(Vector2f point)
- Sets the transformation anchor point from a
Vector2f. - auto isBlendingEnabled() const -> bool
- Returns whether the node renders with blending enabled.
- void setBlendingEnabled(bool blendingEnabled)
- Sets the blending state for node rendering.
- auto srcBlendingFactor() const -> BlendingFactor
- Returns the source blending factor.
- auto destBlendingFactor() const -> BlendingFactor
- Returns the destination blending factor.
- void setBlendingPreset(BlendingPreset blendingPreset)
- Sets source and destination blending factors from a preset.
- void setBlendingFactors(BlendingFactor srcBlendingFactor, BlendingFactor destBlendingFactor)
- Sets specific source and destination blending factors.
-
auto lastFrameRendered() const -> std::
uint32_t - Returns the last frame in which any viewport rendered this node (i.e. it was not culled).
- auto aabb() const -> Rectf
- Returns the axis-aligned bounding box of the node area in the last frame.
Protected functions
- void updateAabb() virtual
- Recalculates the axis-aligned bounding box.
- void updateCulling()
- Called by each viewport update to refresh this node's culling state.
- void shaderHasChanged() pure virtual
- Performs the required tasks upon a change to the shader.
- void updateRenderCommand() pure virtual
- Updates the render command before the node is drawn.
Protected variables
- float width_
- Node width in pixels.
- float height_
- Node height in pixels.
- RenderCommand renderCommand_
- The render command associated with this node.
-
std::
uint32_t lastFrameRendered_ - The last frame in which any viewport rendered this node.
- Rectf aabb_
- Axis-aligned bounding box of the node area.
Constants
- static const Vector2f AnchorCenter
- static const Vector2f AnchorBottomLeft
- static const Vector2f AnchorTopLeft
- static const Vector2f AnchorBottomRight
- static const Vector2f AnchorTopRight
Enum documentation
enum class nCine:: DrawableNode:: BlendingPreset
Presets for source and destination blending factors.
| Enumerators | |
|---|---|
| DISABLED |
Uses |
| ALPHA |
Uses |
| PREMULTIPLIED_ALPHA |
Uses |
| ADDITIVE |
Uses |
| MULTIPLY |
Uses |