Kanzi Framework  3.9.0
Kanzi Engine API
kanzi::GlRenderState Class Reference

OpenGL render state. More...

#include <kanzi/core.ui/platform/graphics_backend/gl/gl_render_state.hpp>

Classes

class  RenderValueInfo
 Render value information. More...
 
union  RenderValueUnion
 Union containing one render value to be arranged into an array. More...
 
struct  TextureRenderValue
 Container for texture render value and the width/height uniforms. More...
 

Public Types

using HandleType = int
 Type for handle identifiers into values in the render state. More...
 

Public Member Functions

void attach (MaterialSharedPtr material)
 Attach to a certain material/node combination. More...
 
bool bind (Renderer &renderer)
 Applies the render state the render state. More...
 
optional< GraphicsBlendModegetBlendModeValue () const
 Get blend mode value. More...
 
template<typename T >
size_t getElementCount (GlRenderState::HandleType handle) const
 Gets the number of elements for given handle. More...
 
template<>
size_t getElementCount (GlRenderState::HandleType handle) const
 GlRenderState::getElementCount() specialization. More...
 
template<typename T >
HandleType getHandle (string_view name)
 Access handle by type. More...
 
template<>
GlRenderState::HandleType getHandle (string_view name)
 GlRenderState::getHandle() specialization. More...
 
MaterialSharedPtr getMaterial () const
 Access material. More...
 
template<typename T >
T getValue (HandleType handle, size_t index) const
 Accesses a value by handle. More...
 
template<typename T >
T getValue (HandleType handle) const
 Accesses a value by handle. More...
 
template<>
TextureSharedPtr getValue (GlRenderState::HandleType handle) const
 GlRenderState::getValue() specialization. More...
 
 GlRenderState ()
 Empty constructor. More...
 
template<typename T >
bool handleMatches (HandleType handle, string_view name) const
 Checks whether given handle matches the current render state. More...
 
template<>
bool handleMatches (GlRenderState::HandleType handle, string_view name) const
 GlRenderState::handleMatches() specialization. More...
 
void reattach ()
 Reattach already-attached material. More...
 
bool setRange (HandleType handle, AbstractRange &range)
 Sets values of a render target array from a range. More...
 
bool setRange (HandleType handle, AbstractRange *range)
 Sets values of a render target array from a range. More...
 
bool setRange (HandleType handle, AbstractRangeSharedPtr range)
 Sets values of a render target array from a range. More...
 
template<typename T >
void setValue (HandleType handle, const T &value, size_t elementIndex)
 Set a render value identified by handle. More...
 
template<typename T >
void setValue (HandleType handle, const T &value)
 Wrapper for setting a render value by handle. More...
 
void setValue (GraphicsBlendMode value)
 Set blend mode value. More...
 

Protected Types

typedef vector< RenderValueInfoRenderValueInfoContainer
 Container for render value information. More...
 
typedef vector< RenderValueUnionRenderValueUnionContainer
 Container for render values. More...
 
typedef vector< TextureRenderValueTextureRenderValueContainer
 Container for texture render values. More...
 

Detailed Description

OpenGL render state.

Member Typedef Documentation

◆ HandleType

Type for handle identifiers into values in the render state.

◆ RenderValueInfoContainer

Container for render value information.

◆ RenderValueUnionContainer

Container for render values.

◆ TextureRenderValueContainer

Container for texture render values.

Constructor & Destructor Documentation

◆ GlRenderState()

kanzi::GlRenderState::GlRenderState ( )
inlineexplicit

Empty constructor.

Member Function Documentation

◆ bind()

bool kanzi::GlRenderState::bind ( Renderer renderer)

Applies the render state the render state.

After calling this function, geometry can be rendered using the render state settings.

Parameters
rendererRenderer to use.
Returns
If the shader program was available and bound, true, otherwise false.

◆ attach()

void kanzi::GlRenderState::attach ( MaterialSharedPtr  material)

Attach to a certain material/node combination.

Parameters
materialMaterial to attach to.

◆ reattach()

void kanzi::GlRenderState::reattach ( )

Reattach already-attached material.

Does nothing if no material attached.

◆ getMaterial()

MaterialSharedPtr kanzi::GlRenderState::getMaterial ( ) const
inline

Access material.

Returns
Pointer to material.

◆ setValue() [1/3]

template<typename T >
void kanzi::GlRenderState::setValue ( HandleType  handle,
const T value,
size_t  elementIndex 
)
inline

Set a render value identified by handle.

The handle may be invalid (negative), in which case this function does nothing.

Parameters
handleIdentifying handle.
valueValue to set.
elementIndexIndex of the element in the value to set.
Returns
If value was successfully set, true, otherwise false.

◆ setValue() [2/3]

template<typename T >
void kanzi::GlRenderState::setValue ( HandleType  handle,
const T value 
)
inline

Wrapper for setting a render value by handle.

Element index is zero.

Parameters
handleIdentifying handle.
valueValue to set.
Returns
If value was successfully set, true, otherwise false.

◆ getBlendModeValue()

optional<GraphicsBlendMode> kanzi::GlRenderState::getBlendModeValue ( ) const
inline

Get blend mode value.

Returns
Optional blend mode value.

◆ setValue() [3/3]

void kanzi::GlRenderState::setValue ( GraphicsBlendMode  value)
inline

Set blend mode value.

Parameters
valueValue.

◆ getHandle() [1/2]

template<typename T >
HandleType kanzi::GlRenderState::getHandle ( string_view  name)
inline

Access handle by type.

Parameters
nameValue name.
Returns
Handle (index) to info array.

◆ getElementCount() [1/2]

template<typename T >
size_t kanzi::GlRenderState::getElementCount ( GlRenderState::HandleType  handle) const
inline

Gets the number of elements for given handle.

Parameters
handleHandle.
Returns
Number of elements for the handle.

◆ getValue() [1/3]

template<typename T >
T kanzi::GlRenderState::getValue ( HandleType  handle,
size_t  index 
) const
inline

Accesses a value by handle.

Handle must be valid, access with invalid handle is undefined behavior.

Parameters
handleHandle to value.
indexIndex of the value to access.
Returns
Value previously stored with the handle.

◆ getValue() [2/3]

template<typename T >
T kanzi::GlRenderState::getValue ( HandleType  handle) const
inline

Accesses a value by handle.

Index of the accessed value is zero.

Parameters
handleHandle to value.
Returns
Value previously stored with the handle.

◆ handleMatches() [1/2]

template<typename T >
bool kanzi::GlRenderState::handleMatches ( HandleType  handle,
string_view  name 
) const
inline

Checks whether given handle matches the current render state.

Parameters
handleHandle to check.
nameName to compare against.
Returns
True if given handle and name match in the render state, false otherwise.

◆ setRange() [1/3]

bool kanzi::GlRenderState::setRange ( HandleType  handle,
AbstractRange range 
)

Sets values of a render target array from a range.

If the array is larger than the range, writes default values to the remaining values in the end of the array.

Parameters
handleHandle from the render state.
rangeRange input.
Returns
If value was successfully set, true, otherwise false.
Since
Kanzi 3.9.0

◆ setRange() [2/3]

bool kanzi::GlRenderState::setRange ( HandleType  handle,
AbstractRange range 
)

Sets values of a render target array from a range.

If the array is larger than the range, writes default values to the remaining values in the end of the array. If the range is a nullptr, sets all the elements of the render target array to default values.

Parameters
handleHandle from the render state.
rangeRange input.
Returns
If value was successfully set, true, otherwise false.
Since
Kanzi 3.9.0

◆ setRange() [3/3]

bool kanzi::GlRenderState::setRange ( HandleType  handle,
AbstractRangeSharedPtr  range 
)

Sets values of a render target array from a range.

If the array is larger than the range, writes default values to the remaining values in the end of the array. If the range is a nullptr, sets all the elements of the render target array to default values.

Parameters
handleHandle from the render state.
rangeRange input.
Returns
If value was successfully set, true, otherwise false.
Since
Kanzi 3.9.0

◆ getHandle() [2/2]

template<>
GlRenderState::HandleType kanzi::GlRenderState::getHandle ( string_view  name)

GlRenderState::getHandle() specialization.

◆ handleMatches() [2/2]

template<>
bool kanzi::GlRenderState::handleMatches ( GlRenderState::HandleType  handle,
string_view  name 
) const

◆ getValue() [3/3]

template<>
TextureSharedPtr kanzi::GlRenderState::getValue ( GlRenderState::HandleType  handle) const

GlRenderState::getValue() specialization.

◆ getElementCount() [2/2]

template<>
size_t kanzi::GlRenderState::getElementCount ( GlRenderState::HandleType  handle) const

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