Kanzi  3.9.5
Kanzi Engine API
kanzi::BrushRenderer Class Referenceabstract

Brush renderer class. More...

#include <kanzi/core.ui/graphics2d/brush_renderer.hpp>

Inheritance diagram for kanzi::BrushRenderer:
[legend]

Public Types

enum  RenderMode { RenderModeNone, RenderModeContent, RenderModeNoContent }
 Enum signifying currently selected render mode. More...
 

Public Member Functions

void bind (Renderer3D &renderer)
 Bind brush renderer for rendering. More...
 
void draw (Renderer &renderer, const Geometry &quad, const Matrix4x4 &transform)
 Draw a brush using given quad. More...
 
void draw (Renderer &renderer, const Geometry &quad, const Matrix3x3 &transform)
 Overload for draw a brush using given quad. More...
 
int getBlendModeValue ()
 Gets the last used blend mode value. More...
 
BrushgetBrush () const
 Access brush. More...
 
TextureSharedPtr getContentTexture () const
 Access content texture. More...
 
virtual MaterialSharedPtr getMaterial ()
 Get currently set material for the renderer. More...
 
NodegetNode () const
 Gets the attached node. More...
 
unsigned int getPropertyChangeCounter () const
 Access property change counter. More...
 
RenderMode getRenderMode () const
 Get currently selected render mode. More...
 
float getRenderOpacity () const
 Access opacity. More...
 
bool hasRenderMode () const
 Indicates whether a valid render mode is selected. More...
 
void restoreResources ()
 Restore resources after sleep. More...
 
void setContentTexture (TextureSharedPtr texture)
 Set a content texture. More...
 
void setRenderOpacity (float opacity)
 Set opacity to use for next attach. More...
 
void updateRender (optional< int > blendMode, bool forceOpaque, bool translucencyHint)
 Called from Node2D::updateRender(). More...
 
virtual ~BrushRenderer ()=default
 Destructor. More...
 

Protected Member Functions

virtual void bindOverride (Renderer3D &renderer)=0
 BrushRenderer-specific bind implementation. More...
 
 BrushRenderer (Brush *brush, Node *node)
 Constructor. More...
 
virtual void drawOverride (Renderer &renderer, const Geometry &geometry, const Matrix4x4 &transform)=0
 Draw geometry using the brush. More...
 
virtual int getBlendModeValueOverride ()=0
 BrushRenderer-specific acquisition of last-used blend mode. More...
 
bool isChangeCounterSame () const
 Checks whether the property change counter matches that of the brush. More...
 
virtual void restoreResourcesOverride ()=0
 BrushRenderer-specific restore resources implementation. More...
 
virtual void setContentTextureOverride (TextureSharedPtr texture)
 BrushRenderer-specific update of the content texture. More...
 
void setRenderMode (RenderMode selection)
 Set render mode. More...
 
void updateChangeCounter ()
 Updates property change counter to match the counter value from brush. More...
 
virtual void updateRenderOverride (optional< int > blendMode, bool forceOpaque, bool translucencyHint)=0
 BrushRenderer-specific opacity override implementation. More...
 

Protected Attributes

Brushm_brush
 Brush attached to. More...
 
unsigned int m_brushPropertyChangeCounter
 Property change counter to track brush. More...
 
TextureSharedPtr m_contentTexture
 Content texture provided to the brush renderer from outside, e.g. from Node2D. More...
 
Nodem_node
 Node attached to. More...
 
RenderMode m_renderMode
 Currently used render mode (or none if not selected). More...
 
float m_renderOpacity
 Opacity to issue on attach. More...
 

Detailed Description

Brush renderer class.

Just an interface, actual rendering will be implemented by specialized brush renderers.

Member Enumeration Documentation

◆ RenderMode

Enum signifying currently selected render mode.

Enumerator
RenderModeNone 

No selection.

RenderModeContent 

Content specified for brush.

Since
Kanzi 3.9.1
RenderModeNoContent 

No content specified for brush.

Since
Kanzi 3.9.1

Constructor & Destructor Documentation

◆ ~BrushRenderer()

virtual kanzi::BrushRenderer::~BrushRenderer ( )
virtualdefault

Destructor.

◆ BrushRenderer()

kanzi::BrushRenderer::BrushRenderer ( Brush brush,
Node node 
)
explicitprotected

Constructor.

Parameters
nodeThe node to which to attach.
brushThe brush to which to attach.

Member Function Documentation

◆ updateRender()

void kanzi::BrushRenderer::updateRender ( optional< int >  blendMode,
bool  forceOpaque,
bool  translucencyHint 
)
inline

Called from Node2D::updateRender().

Prepares a brush for rendering. Call this function when the brush material or attached nodes have changed. Unlike bind(), updateRender() does not need to be called every frame before draw().

Parameters
blendModeOptional blend mode override.
forceOpaqueWhether to select the opaque render mode in any case.
translucencyHintAdditional hint to use translucent rendering.
Since
Kanzi 3.9.1 added blendMode parameter.

◆ bind()

void kanzi::BrushRenderer::bind ( Renderer3D renderer)
inline

Bind brush renderer for rendering.

Must be called before calling draw().

Parameters
rendererRenderer to use.

◆ draw() [1/2]

void kanzi::BrushRenderer::draw ( Renderer renderer,
const Geometry quad,
const Matrix4x4 transform 
)

Draw a brush using given quad.

Parameters
rendererRenderer to use.
quadQuad to draw.
transformThe transform as a 4x4 matrix to use.

◆ draw() [2/2]

void kanzi::BrushRenderer::draw ( Renderer renderer,
const Geometry quad,
const Matrix3x3 transform 
)
inline

Overload for draw a brush using given quad.

Parameters
rendererRenderer to use.
quadQuad to draw.
transformThe transform as a 3x3 matrix to use.

◆ restoreResources()

void kanzi::BrushRenderer::restoreResources ( )
inline

Restore resources after sleep.

◆ getBrush()

Brush* kanzi::BrushRenderer::getBrush ( ) const
inline

Access brush.

Returns
Brush pointer.

◆ getPropertyChangeCounter()

unsigned int kanzi::BrushRenderer::getPropertyChangeCounter ( ) const
inline

Access property change counter.

◆ getRenderOpacity()

float kanzi::BrushRenderer::getRenderOpacity ( ) const
inline

Access opacity.

Returns
Current render opacity.

◆ setRenderOpacity()

void kanzi::BrushRenderer::setRenderOpacity ( float  opacity)
inline

Set opacity to use for next attach.

Parameters
opacityNew render opacity.

◆ getContentTexture()

TextureSharedPtr kanzi::BrushRenderer::getContentTexture ( ) const
inline

Access content texture.

Returns
Current content texture.

◆ setContentTexture()

void kanzi::BrushRenderer::setContentTexture ( TextureSharedPtr  texture)
inline

Set a content texture.

Parameters
textureNew render texture.

◆ getNode()

Node* kanzi::BrushRenderer::getNode ( ) const
inline

Gets the attached node.

Returns
Node pointer.

◆ getRenderMode()

RenderMode kanzi::BrushRenderer::getRenderMode ( ) const
inline

Get currently selected render mode.

Returns
Current render mode.

◆ hasRenderMode()

bool kanzi::BrushRenderer::hasRenderMode ( ) const
inline

Indicates whether a valid render mode is selected.

Returns
If a render mode has been selected, true, otherwise false.

◆ getMaterial()

virtual MaterialSharedPtr kanzi::BrushRenderer::getMaterial ( )
inlinevirtual

Get currently set material for the renderer.

Returns
Shared pointer to the material that is currently set for the brush renderer. If not set, returns nullptr.

Reimplemented in kanzi::MaterialBrushRenderer, and kanzi::ContentBrushRenderer.

◆ getBlendModeValue()

int kanzi::BrushRenderer::getBlendModeValue ( )
inline

Gets the last used blend mode value.

This function is intended for tests.

Returns
Blend mode.
Since
Kanzi 3.9.1

◆ drawOverride()

virtual void kanzi::BrushRenderer::drawOverride ( Renderer renderer,
const Geometry geometry,
const Matrix4x4 transform 
)
protectedpure virtual

Draw geometry using the brush.

To be implemented by specific brush implementations.

Parameters
rendererRenderer to use.
geometryQuad to draw.
transformTransform to use.

Implemented in kanzi::ContentBrushRenderer, kanzi::MaterialBrushRenderer, kanzi::TextureBrushRenderer, and kanzi::ColorBrushRenderer.

◆ bindOverride()

virtual void kanzi::BrushRenderer::bindOverride ( Renderer3D renderer)
protectedpure virtual

BrushRenderer-specific bind implementation.

Parameters
rendererRenderer to use.

Implemented in kanzi::MaterialBrushRenderer, kanzi::ContentBrushRenderer, kanzi::TextureBrushRenderer, and kanzi::ColorBrushRenderer.

◆ updateRenderOverride()

virtual void kanzi::BrushRenderer::updateRenderOverride ( optional< int >  blendMode,
bool  forceOpaque,
bool  translucencyHint 
)
protectedpure virtual

BrushRenderer-specific opacity override implementation.

Parameters
blendModeOptional blend mode override.
forceOpaqueWhether to select the opaque render mode in any case.
translucencyHintAdditional hint to use translucent rendering.
Since
Kanzi 3.9.1 added blendMode parameter.

Implemented in kanzi::ContentBrushRenderer, kanzi::MaterialBrushRenderer, kanzi::TextureBrushRenderer, and kanzi::ColorBrushRenderer.

◆ restoreResourcesOverride()

virtual void kanzi::BrushRenderer::restoreResourcesOverride ( )
protectedpure virtual

BrushRenderer-specific restore resources implementation.

Implemented in kanzi::ContentBrushRenderer, kanzi::MaterialBrushRenderer, kanzi::TextureBrushRenderer, and kanzi::ColorBrushRenderer.

◆ getBlendModeValueOverride()

virtual int kanzi::BrushRenderer::getBlendModeValueOverride ( )
protectedpure virtual

BrushRenderer-specific acquisition of last-used blend mode.

Returns
Blend mode used for rendering.
Since
Kanzi 3.9.1

Implemented in kanzi::ContentBrushRenderer, and kanzi::MaterialBrushRenderer.

◆ setContentTextureOverride()

virtual void kanzi::BrushRenderer::setContentTextureOverride ( TextureSharedPtr  texture)
inlineprotectedvirtual

BrushRenderer-specific update of the content texture.

Parameters
textureNew renderer texture.
Since
Kanzi 3.9.5

Reimplemented in kanzi::ColorBrushRenderer.

◆ setRenderMode()

void kanzi::BrushRenderer::setRenderMode ( RenderMode  selection)
inlineprotected

Set render mode.

Parameters
selectionNew render mode selection.

◆ isChangeCounterSame()

bool kanzi::BrushRenderer::isChangeCounterSame ( ) const
protected

Checks whether the property change counter matches that of the brush.

Returns
If the property change counter matches and no update is needed, true, otherwise false.

◆ updateChangeCounter()

void kanzi::BrushRenderer::updateChangeCounter ( )
protected

Updates property change counter to match the counter value from brush.

Member Data Documentation

◆ m_brush

Brush* kanzi::BrushRenderer::m_brush
protected

Brush attached to.

Since
Kanzi 3.9.1 protection changed from private to protected.

◆ m_node

Node* kanzi::BrushRenderer::m_node
protected

Node attached to.

◆ m_contentTexture

TextureSharedPtr kanzi::BrushRenderer::m_contentTexture
protected

Content texture provided to the brush renderer from outside, e.g. from Node2D.

◆ m_renderMode

RenderMode kanzi::BrushRenderer::m_renderMode
protected

Currently used render mode (or none if not selected).

◆ m_renderOpacity

float kanzi::BrushRenderer::m_renderOpacity
protected

Opacity to issue on attach.

◆ m_brushPropertyChangeCounter

unsigned int kanzi::BrushRenderer::m_brushPropertyChangeCounter
protected

Property change counter to track brush.


The documentation for this class was generated from the following file: