![]() |
Maria GDK 5.0.0.738
Documentation of native code in develop branch
|
#include <StkRenderItem2D.h>
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::Matrix4x4f & | getTransform () |
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::Vector2f & | getPosition () 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::Matrix4x4f > | getPreTransform () const |
std::optional< STK::Matrix4x4f > | getPostTransform () 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::Matrix4x4f > | pre_transform_ |
std::optional< STK::Matrix4x4f > | post_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 |
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.
|
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.
|
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.
|
inline |
Returns current scale factor for the item.
|
inline |
Stencil buffer operations.
Get currently enabled stencil operating mode.
|
inline |
Get value for stencil operations.
|
inline |
Returns the current graphics transform for this item.
|
pure virtual |
Get bounding box in viewport pixel coordinates.
mvp | Projection/Modelview matrix. |
glVp | OpenGL viewport |
reverse_y | If 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. |
Implemented in STK::FixedScaleRenderItem, Maria::MinefieldFillRender2D, Maria::YardstickRenderItem, STK::EllipseRender2D, STK::IconRenderItem, STK::PolygonRender2D, STK::PolylineRender2D, and STK::TextRenderItem.
|
pure virtual |
Render item into the current frame. This method should render a single item into the GraphicsRender2D.
Implemented in STK::EllipseRender2D, STK::IconRenderItem, STK::PolygonRender2D, STK::PolylineRender2D, STK::TextRenderItem, STK::TextRenderItemSDF, Maria::CustomPolygonRenderer2D, Maria::CustomTextRenderItem, Maria::CustomTextRenderItemSDF, Maria::MinefieldFillRender2D, Maria::YardstickRenderItem, and STK::FixedScaleRenderItem.
|
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.
angle | Rotation angle (in degrees). |
|
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.
|
inline |
Same as above.
pos | New position (in pixels). |
|
inline |
Set 2D position of the item. This method will invalidate the transform and cause it to be recalculated on the next frame.
x | X position (in pixels) |
y | Y position (in pixels) |
|
inline |
|
inline |
|
inline |
Set post multiplicated transform Set an extra transformation which is added after the regular item 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.
|
inline |
Set scale factor for the text item. This method will invalidate the transform and cause it to be recalculated on the next frame.
scale |
|
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.
mode | Stencil operation mode. |
|
inline |
Set value for stencil operations.
stencil_value | 8-bit value to be written or tested for in stencil operations. |
|
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.
transform |