Maria GDK 5.0.0.738
Documentation of native code in develop branch
Loading...
Searching...
No Matches
STK::RenderItem2D Class Referenceabstract

#include <StkRenderItem2D.h>

Inheritance diagram for STK::RenderItem2D:
Maria::EntityBadge Maria::MinefieldFillRender2D Maria::YardstickRenderItem STK::EllipseRender2D STK::FixedScaleRenderItem STK::IconRenderItem STK::PolygonRender2D STK::PolylineRender2D STK::TextRenderItem

Public Member Functions

virtual void render (GraphicsRender2D &renderer, const STK::Matrix4x4f &pj, const STK::Matrix4x4f &vm, const STK::Viewport &vp)=0
 
virtual void cleanupBuffers ()=0
 
virtual int getBatchId () const =0
 
void setDepth (float depth)
 
float getDepth () const
 
void setStencilValue (unsigned char stencil_value)
 Set value for stencil operations.
 
unsigned char getStencilValue () const
 Get value for stencil operations.
 
void setStencilMode (StencilMode mode)
 Stencil buffer operations.
 
StencilMode getStencilMode () const
 Stencil buffer operations.
 
const STK::Matrix4x4fgetTransform ()
 
void setPosition (float x, float y)
 Set 2D position of the item. This method will invalidate the transform and cause it to be recalculated on the next frame.
 
void setPosition (const STK::Vector2f &pos)
 Same as above.
 
void setPositionX (float x)
 Set X position separately.
 
void setPositionY (float y)
 Set Y position separately.
 
const STK::Vector2fgetPosition () const
 
float getPositionX () const
 
float getPositionY () const
 
void setScale (const STK::Vector2f &scale)
 
void setScale (float scale)
 Set scale factor for the text item. This method will invalidate the transform and cause it to be recalculated on the next frame.
 
STK::Vector2f getScale () const
 Returns current scale factor for the item.
 
void setAngle (float angle)
 Set rotation angle for the item. Positive rotation direction is counter-clockwise. This method will invalidate the transform and cause it to be recalculated on the next frame.
 
float getAngle () const
 
void setTransform (const STK::Matrix4x4f &transform)
 Set transform directly. This method will set the transformation matrix for this item directly. This will override any values for setPosition(), setScale(), setDepth() and setAngle(). Also, any subsequent calls to these methods will again override this method. In short, either use setTransform() or setPosition/Scale/Angle/Depth.
 
void setPreTransform (const STK::Matrix4x4f &transform)
 
void setPostTransform (const STK::Matrix4x4f &transform)
 
std::optional< STK::Matrix4x4fgetPreTransform () const
 
std::optional< STK::Matrix4x4fgetPostTransform () const
 
void setOpacity (float opacity)
 
float getOpacity () const
 
virtual STK::Box2< float > getViewBoundingBox (const STK::Matrix4x4f &mvp, const STK::Viewport &glVp, bool reverse_y=false)=0
 Get bounding box in viewport pixel coordinates.
 

Protected Member Functions

virtual void updateTransform ()
 
void setViewScale (float x, float y)
 

Protected Attributes

float depth_ = 0
 
STK::Matrix4x4f transform_
 
STK::Vector2f pos_
 
float angle_ = 0.0f
 
float opacity_ = 1.0f
 
STK::Vector2f scale_ { 1.0f, 1.0f }
 
bool transform_dirty_ = false
 
std::optional< STK::Matrix4x4fpre_transform_
 
std::optional< STK::Matrix4x4fpost_transform_
 
std::mutex xfm_mutex_
 
unsigned char stencil_value_ = 0
 
StencilMode stencil_mode_ = StencilMode::NONE
 
float view_scale_x_ = 1.0f
 
float view_scale_y_ = 1.0f
 

Detailed Description

RenderItem2D - Base class for all 2D render items. This class is responsible for sorting render items most efficiently.

Items should be sorted primarily on depth so that higher depths are rendered before lower depths.

Next, the items are sorted on on the batch_id_ id which is typically a number assigned to each render item type so that all polygons on the same depth are rendered together, all lines on the same depth are rendered together, etc.

Member Function Documentation

◆ cleanupBuffers()

virtual void STK::RenderItem2D::cleanupBuffers ( )
pure virtual

Clean up OpenGL graphics objects This method should clean up all OpenGL related buffers and objects. This is normally called by GraphicsRender2D::cleanup()

Implemented in Maria::MinefieldFillRender2D, Maria::YardstickRenderItem, STK::EllipseRender2D, STK::FixedScaleRenderItem, STK::IconRenderItem, STK::PolygonRender2D, STK::PolylineRender2D, and STK::TextRenderItem.

◆ getBatchId()

virtual int STK::RenderItem2D::getBatchId ( ) const
pure virtual

Render batch id. This number indicates which item should be rendered together if the depths are equal.

Implemented in Maria::MinefieldFillRender2D, Maria::YardstickRenderItem, STK::EllipseRender2D, STK::FixedScaleRenderItem, STK::IconRenderItem, STK::PolygonRender2D, STK::PolylineRender2D, STK::TextRenderItem, and STK::TextRenderItemSDF.

◆ getScale()

STK::Vector2f STK::RenderItem2D::getScale ( ) const
inline

Returns current scale factor for the item.

Returns

◆ getStencilMode()

StencilMode STK::RenderItem2D::getStencilMode ( ) const
inline

Stencil buffer operations.

Get currently enabled stencil operating mode.

◆ getStencilValue()

unsigned char STK::RenderItem2D::getStencilValue ( ) const
inline

Get value for stencil operations.

Returns

◆ getTransform()

const STK::Matrix4x4f & STK::RenderItem2D::getTransform ( )
inline

Returns the current graphics transform for this item.

◆ getViewBoundingBox()

virtual STK::Box2< float > STK::RenderItem2D::getViewBoundingBox ( const STK::Matrix4x4f mvp,
const STK::Viewport glVp,
bool  reverse_y = false 
)
pure virtual

Get bounding box in viewport pixel coordinates.

Parameters
mvpProjection/Modelview matrix.
glVpOpenGL viewport
reverse_yIf true, any pixel coordinate calculations are using positive y direction downwards. This applies for example to text and icon items which have separate pixel coordinate transforms.
Returns
Min/Max coordinates for the object in pixel coordinates.

Implemented in STK::FixedScaleRenderItem, Maria::MinefieldFillRender2D, Maria::YardstickRenderItem, STK::EllipseRender2D, STK::IconRenderItem, STK::PolygonRender2D, STK::PolylineRender2D, and STK::TextRenderItem.

◆ render()

virtual void STK::RenderItem2D::render ( GraphicsRender2D renderer,
const STK::Matrix4x4f pj,
const STK::Matrix4x4f vm,
const STK::Viewport vp 
)
pure virtual

◆ setAngle()

void STK::RenderItem2D::setAngle ( float  angle)
inline

Set rotation angle for the item. Positive rotation direction is counter-clockwise. This method will invalidate the transform and cause it to be recalculated on the next frame.

Parameters
angleRotation angle (in degrees).

◆ setDepth()

void STK::RenderItem2D::setDepth ( float  depth)
inline

Render depth. Objects with lower depth are rendered in front of objects with higher depth. Range is arbitrary, both negative and positive values are allowed.

◆ setPosition() [1/2]

void STK::RenderItem2D::setPosition ( const STK::Vector2f pos)
inline

Same as above.

Parameters
posNew position (in pixels).

◆ setPosition() [2/2]

void STK::RenderItem2D::setPosition ( float  x,
float  y 
)
inline

Set 2D position of the item. This method will invalidate the transform and cause it to be recalculated on the next frame.

Parameters
xX position (in pixels)
yY position (in pixels)

◆ setPositionX()

void STK::RenderItem2D::setPositionX ( float  x)
inline

Set X position separately.

See also
setPosition

setPosition

Parameters
xX position (in pixels)

◆ setPositionY()

void STK::RenderItem2D::setPositionY ( float  y)
inline

Set Y position separately.

See also
setPosition

setPosition

Parameters
yY position (in pixels)

◆ setPostTransform()

void STK::RenderItem2D::setPostTransform ( const STK::Matrix4x4f transform)
inline

Set post multiplicated transform Set an extra transformation which is added after the regular item transform.

◆ setPreTransform()

void STK::RenderItem2D::setPreTransform ( const STK::Matrix4x4f transform)
inline

Set pre multiplicated transform Set an extra transformation which is added before the regular item transform. May be useful for example when moving a group of objects while retaining their positions relative to each other.

◆ setScale()

void STK::RenderItem2D::setScale ( float  scale)
inline

Set scale factor for the text item. This method will invalidate the transform and cause it to be recalculated on the next frame.

Parameters
scale

◆ setStencilMode()

void STK::RenderItem2D::setStencilMode ( StencilMode  mode)
inline

Stencil buffer operations.

This method can be used to enable stencil buffer operations on this render item. These operations are either writing the render item to the stencil buffer, or test for certain stencil buffer values while rendering. This can typically be used for masking graphics.

Parameters
modeStencil operation mode.

◆ setStencilValue()

void STK::RenderItem2D::setStencilValue ( unsigned char  stencil_value)
inline

Set value for stencil operations.

Parameters
stencil_value8-bit value to be written or tested for in stencil operations.

◆ setTransform()

void STK::RenderItem2D::setTransform ( const STK::Matrix4x4f transform)
inline

Set transform directly. This method will set the transformation matrix for this item directly. This will override any values for setPosition(), setScale(), setDepth() and setAngle(). Also, any subsequent calls to these methods will again override this method. In short, either use setTransform() or setPosition/Scale/Angle/Depth.

Parameters
transform

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