Lysa  0.0
Lysa 3D Engine
Vector2DRenderer Class Reference

Detailed Description

Renderer for 2D vector graphics

+ Inheritance diagram for Vector2DRenderer:

Public Member Functions

 Vector2DRenderer (const RendererConfiguration &config, vireo::ImageFormat outputFormat)
 
void resize (const vireo::Extent &extent)
 
auto getAspectRatio () const
 
void drawLine (const float2 &start, const float2 &end)
 
void drawFilledRect (const Rect &rect)
 
void drawFilledRect (const Rect &rect, unique_id texture)
 
void drawFilledRect (float x, float y, float w, float h, unique_id texture=INVALID_ID)
 
void drawText (const std::string &text, Font &font, float fontScale, float x, float y)
 
auto setPenColor (const float4 &color)
 
auto setTranslate (const float2 &t)
 
auto setTransparency (const float a)
 
- Public Member Functions inherited from Vector3DRenderer
 Vector3DRenderer (const RendererConfiguration &config, vireo::ImageFormat outputFormat, bool useCamera=true, bool depthTestEnable=true, bool filledTriangles=false, bool enableAlphaBlending=true, const std::string &name="VectorRenderer", const std::string &shadersName="vector", const std::string &glyphShadersName="glyph")
 
bool isUseCamera () const
 
void drawLine (const float3 &from, const float3 &to, const float4 &color)
 
void drawTriangle (const float3 &v1, const float3 &v2, const float3 &v3, const float4 &color)
 
void drawImage (unique_id image, const float3 &position, const quaternion &rotation, const float2 &size, const float4 &color)
 
void drawText (const std::string &text, Font &font, float fontScale, const float3 &position, const quaternion &rotation, const float4 &innerColor)
 
void restart ()
 
void update (const vireo::CommandList &commandList, uint32 frameIndex)
 
void render (vireo::CommandList &commandList, const Camera &camera, const std::shared_ptr< vireo::RenderTarget > &colorAttachment, const std::shared_ptr< vireo::RenderTarget > &depthAttachment, uint32 frameIndex)
 
virtual ~Vector3DRenderer () = default
 
 Vector3DRenderer (Vector3DRenderer &) = delete
 
Vector3DRenderer & operator= (Vector3DRenderer &) = delete
 

Additional Inherited Members

- Protected Member Functions inherited from Vector3DRenderer
int32 addTexture (const Image &texture)
 
int32 addFont (const Font &font)
 
- Protected Attributes inherited from Vector3DRenderer
ImageManagerimageManager
 
const RendererConfigurationconfig
 
bool vertexBufferDirty {true}
 
std::vector< VertexlinesVertices
 
std::vector< VertextriangleVertices
 
std::vector< VerteximagesVertices
 
std::vector< VertexglyphVertices
 

Constructor & Destructor Documentation

Vector2DRenderer ( const RendererConfiguration config,
vireo::ImageFormat  outputFormat 
)

Constructs a new Vector2DRenderer

Parameters
configThe renderer configuration
outputFormat

Member Function Documentation

void drawFilledRect ( const Rect rect)

Draws a filled rectangle

Parameters
rectThe rectangle to draw
void drawFilledRect ( const Rect rect,
unique_id  texture 
)

Draws a filled rectangle with an image texture

Parameters
rectThe rectangle to draw
textureThe unique ID of the texture to use
void drawFilledRect ( float  x,
float  y,
float  w,
float  h,
unique_id  texture = INVALID_ID 
)

Draws a filled rectangle with an optional texture

Parameters
xThe x-coordinate of the rectangle
yThe y-coordinate of the rectangle
wThe width of the rectangle
hThe height of the rectangle
textureThe unique ID of the texture to use (defaults to INVALID_ID)
void drawLine ( const float2 &  start,
const float2 &  end 
)

Draws a 1-fragment width line

Parameters
startThe starting point of the line
endThe ending point of the line
void drawText ( const std::string &  text,
Font font,
float  fontScale,
float  x,
float  y 
)

Draws text on the screen

Parameters
textThe text string to draw
fontThe font to use for drawing
fontScaleThe scale of the font
xThe x-coordinate where the text starts
yThe y-coordinate where the text starts
auto getAspectRatio ( ) const
inline

Gets the aspect ratio of the renderer

Returns
The current aspect ratio
void resize ( const vireo::Extent &  extent)

Resizes the renderer's viewport

Parameters
extentThe new extent
auto setPenColor ( const float4 &  color)
inline

Changes the color of the fragments for the next drawing commands

Parameters
colorThe new pen color
auto setTranslate ( const float2 &  t)
inline

Changes the [x,y] translation for the next drawing commands

Parameters
tThe translation vector
auto setTransparency ( const float  a)
inline

Changes the global transparency for the next drawing commands

The value is subtracted from the vertex alpha

Parameters
aThe transparency value