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

#include <StkPolylineRender2D.h>

Inheritance diagram for STK::PolylineRender2D:
STK::RenderItem2D

Classes

struct  LineItem
 

Public Types

enum class  TextureAlignment { Center , Above , Below }
 

Public Member Functions

 PolylineRender2D (const std::vector< Vector2f > &vtx, const STK::Color4f &color, float lineThickness=1.0)
 
void setNumLineItems (int n)
 
int getNumLineItems () const
 
void clearLineItems ()
 
void setDynamicData (bool dynamic_data)
 
bool isDynamicData () const
 
void addLineItemVertices (const std::vector< Vector2f > &vtx, bool closed=false)
 
void setVertices (const std::vector< Vector2f > &vtx, int i=0)
 
void addVertex (const STK::Vector2f &v, int i=0)
 
void setNumVertices (int n, int i=0)
 
void setVertex (int j, const STK::Vector2f &v, int i=0)
 
void setClosed (bool closed, int i=0)
 
bool isClosed (int i=0) const
 
const STK::Vector2fgetVertex (int j, int i=0) const
 
int getNumVertices (int i=0) const
 
const std::vector< STK::Vector2f > & getVertices (int i=0) const
 
void setLineThickness (float w)
 Set line thickness (in pixels).
 
float getLineThickness () const
 Get line thickness (in pixels).
 
void setLineSmoothing (float s)
 
float getLineSmoothing () const
 Get line smoothing (in pixels).
 
void setColor (const STK::Color4f &color)
 Set line color.
 
const STK::Color4fgetColor () const
 Get line color.
 
void setFixedSize (bool fixed)
 
bool getFixedSize () const
 
void setDashes (const std::vector< unsigned char > &pattern)
 
const std::vector< unsigned char > & getDashes () const
 
bool isStippled () const
 
bool hasTexture () const
 
void setTexture (const std::shared_ptr< STK::Texture > &tex, float tex_length, TextureAlignment tex_align, float tex_offset=0.0f)
 
float getTextureLength () const
 
void setTextureLength (float tex_length)
 
void setTextureBorder (float tex_border)
 
float getTextureBorder () const
 
void setSnapTextureCoords (bool snap_tex_coords)
 
bool snapTextureCoords () const
 
void setTextureOffset (float tex_offset)
 
float getTextureOffset () const
 
TextureAlignment getTextureAlignment () const
 
void setTextureAlignment (TextureAlignment tex_align)
 
const std::shared_ptr< STK::Texture > & getTexture () const
 
void setRoundingAngleLimit (float radians)
 
float getRoundingAngleLimit () const
 
void drawVertexArrays ()
 
void render (GraphicsRender2D &renderer, const STK::Matrix4x4f &pj, const STK::Matrix4x4f &vm, const STK::Viewport &vp) override
 
int getBatchId () const override
 
void cleanupBuffers () override
 
virtual STK::Box2< float > getViewBoundingBox (const STK::Matrix4x4f &mvp, const STK::Viewport &glVp, bool reverse_y=false) override
 Get bounding box in viewport pixel coordinates.
 
- Public Member Functions inherited from STK::RenderItem2D
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.
 

Static Public Member Functions

static TextureAlignment parseTextureAlignment (const std::string &s, TextureAlignment defaultValue=TextureAlignment::Center)
 

Additional Inherited Members

- Protected Member Functions inherited from STK::RenderItem2D
virtual void updateTransform ()
 
void setViewScale (float x, float y)
 
- Protected Attributes inherited from STK::RenderItem2D
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

PolylineRender2D - This class handles rendering of a batch of polyline items. Each item in the batch will have the same color and line width, but need not be connected.

The api is simplified so that if you only have one line item, you need not specify index for it. (The first item is assumed if not specified).

Member Function Documentation

◆ addLineItemVertices()

void STK::PolylineRender2D::addLineItemVertices ( const std::vector< Vector2f > &  vtx,
bool  closed = false 
)
inline

Add a line item with vertices. This method will create a new LineItem and add it to the end of the list.

◆ addVertex()

void STK::PolylineRender2D::addVertex ( const STK::Vector2f v,
int  i = 0 
)
inline

Append vertex. This method will append a vertex to the end of the given line item, i. If no item is specified, the first item is assumed.

◆ cleanupBuffers()

void PolylineRender2D::cleanupBuffers ( )
overridevirtual

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

Implements STK::RenderItem2D.

◆ drawVertexArrays()

void STK::PolylineRender2D::drawVertexArrays ( )
inline

Draw vertex buffers. Low level rendering of the vertex buffers. Needs the correct shader and uniforms to be set first. This method is normally called by the GraphicsRender2D class.

◆ getBatchId()

int STK::PolylineRender2D::getBatchId ( ) const
overridevirtual

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

Implements STK::RenderItem2D.

◆ getNumVertices()

int STK::PolylineRender2D::getNumVertices ( int  i = 0) const
inline

Get number of vertices in line item. This method will return the number of vertices in the given line item, i. If no item is specified, the first item is assumed.

◆ getRoundingAngleLimit()

float STK::PolylineRender2D::getRoundingAngleLimit ( ) const
inline

Get rounding angle limit (in radians). This is the maximum angle of a line bend before we make a rounded corner.

◆ getVertex()

const STK::Vector2f & STK::PolylineRender2D::getVertex ( int  j,
int  i = 0 
) const
inline

Get vertex from line item. Get the j'th vertex of the given line item i. If no item is specified, the first item is assumed.

◆ getVertices()

const std::vector< STK::Vector2f > & STK::PolylineRender2D::getVertices ( int  i = 0) const
inline

Get all vertices for a line item. If no item is specified, the first item is assumed.

◆ getViewBoundingBox()

STK::Box2< float > STK::PolylineRender2D::getViewBoundingBox ( const STK::Matrix4x4f mvp,
const STK::Viewport glVp,
bool  reverse_y = false 
)
overridevirtual

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.

Implements STK::RenderItem2D.

◆ isClosed()

bool STK::PolylineRender2D::isClosed ( int  i = 0) const
inline

Check if line item is closed. This method returns true if the i'th line item is closed. If no item is specified, the first item is assumed.

◆ render()

void STK::PolylineRender2D::render ( GraphicsRender2D renderer,
const STK::Matrix4x4f pj,
const STK::Matrix4x4f vm,
const STK::Viewport vp 
)
overridevirtual

Render item into the current frame. This method should render a single item into the GraphicsRender2D.

Implements STK::RenderItem2D.

◆ setClosed()

void STK::PolylineRender2D::setClosed ( bool  closed,
int  i = 0 
)
inline

Set line item to closed. This will set the given line item i to closed or not. A closed line item will have its last vertex joined with its first. If no item is specified, the first item is assumed.

◆ setDashes()

void STK::PolylineRender2D::setDashes ( const std::vector< unsigned char > &  pattern)
inline

Set stippling as a pattern of alternating dashes and spaces.

◆ setDynamicData()

void STK::PolylineRender2D::setDynamicData ( bool  dynamic_data)
inline

Optimize for changing data. If set to true, the underlying graphics object will be optimized for changing data. Use this if you need to update the vertices often.

◆ setFixedSize()

void STK::PolylineRender2D::setFixedSize ( bool  fixed)
inline

Set object to be fixed size (in pixels). If true, any viewport scaling will not affect the vertices of this object. All transforms that are set explicitly on the object through INativeRenderItem2D (Position, Scale, Rotation) will still be applied.

◆ setLineSmoothing()

void STK::PolylineRender2D::setLineSmoothing ( float  s)
inline

Set line smoothing (in pixels). This parameter controls the smoothing of the line segments. (Antialiasing). The outer edge of the line is faded to zero over the distance of this value in pixels.

◆ setNumLineItems()

void STK::PolylineRender2D::setNumLineItems ( int  n)
inline

Allocate space for at least n line items. If capcity is high enough, nothing is done.

◆ setRoundingAngleLimit()

void STK::PolylineRender2D::setRoundingAngleLimit ( float  radians)
inline

Set rounding angle limit (in radians). This is the maximum angle of a line bend before we make a rounded corner.

◆ setSnapTextureCoords()

void STK::PolylineRender2D::setSnapTextureCoords ( bool  snap_tex_coords)
inline

Snap texture coordinates to whole integers. This is useful if you have a repeating pattern texture and you want it to snap to whole pattern periods near the vertices. It is however, not useful if the polyline consists of very short segments.

◆ setTextureBorder()

void STK::PolylineRender2D::setTextureBorder ( float  tex_border)
inline

Texture border (in pixels). Set to the number of pixels you want added extra on the outside of the texture pattern. Useful for smoothing/antialiasing.

◆ setTextureOffset()

void STK::PolylineRender2D::setTextureOffset ( float  tex_offset)
inline

Set lateral offset of the texture. This parameter adjusts the sideways placement of the texture, as a fraction of line width. 0 is no offset, 1.0 places the pattern one linewidth to the side of the line.

◆ setVertex()

void STK::PolylineRender2D::setVertex ( int  j,
const STK::Vector2f v,
int  i = 0 
)
inline

Set vertex. This method will set the vertex j, in the given line item, i. If no item is specified, the first item is assumed.

◆ setVertices()

void STK::PolylineRender2D::setVertices ( const std::vector< Vector2f > &  vtx,
int  i = 0 
)
inline

Set vertices. This method will set the vertices of the given line item, i. If no item is specified, the first item is assumed.


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