![]() |
Maria GDK 5.0.0.738
Documentation of native code in develop branch
|
#include <StkPolylineRender2D.h>
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::Vector2f & | getVertex (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::Color4f & | getColor () 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. | |
![]() | |
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. | |
Static Public Member Functions | |
static TextureAlignment | parseTextureAlignment (const std::string &s, TextureAlignment defaultValue=TextureAlignment::Center) |
Additional Inherited Members | |
![]() | |
virtual void | updateTransform () |
void | setViewScale (float x, float y) |
![]() | |
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 |
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).
|
inline |
Add a line item with vertices. This method will create a new LineItem and add it to the end of the list.
|
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.
|
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.
|
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.
|
overridevirtual |
Render batch id. This number indicates which item should be rendered together if the depths are equal.
Implements STK::RenderItem2D.
|
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.
|
inline |
Get rounding angle limit (in radians). This is the maximum angle of a line bend before we make a rounded corner.
|
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.
|
inline |
Get all vertices for a line item. If no item is specified, the first item is assumed.
|
overridevirtual |
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. |
Implements STK::RenderItem2D.
|
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.
|
overridevirtual |
Render item into the current frame. This method should render a single item into the GraphicsRender2D.
Implements STK::RenderItem2D.
|
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.
|
inline |
Set stippling as a pattern of alternating dashes and spaces.
|
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.
|
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.
|
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.
|
inline |
Allocate space for at least n line items. If capcity is high enough, nothing is done.
|
inline |
Set rounding angle limit (in radians). This is the maximum angle of a line bend before we make a rounded corner.
|
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.
|
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.
|
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.
|
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.
|
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.