Lysa  0.0
Lysa 3D Engine
VectorRenderer Class Reference

Detailed Description

Immediate-style 2D/3D vector renderer used for debug and UI primitives.

  • Accumulate simple geometric primitives (lines, triangles, glyph quads) into CPU-side vertex arrays and stream them to the GPU when required.
  • Provide minimal state (colors, textures, fonts) and pipelines to draw primitive batches either in screen space or with a camera.
  • Offer helpers to render text using bitmap fonts.

Notes:

  • Thread-safety: calls are expected from the render thread only.
  • Call restart() between frames to clear accumulated geometry.
+ Inheritance diagram for VectorRenderer:

Classes

struct  Vertex
 

Public Member Functions

 VectorRenderer (bool depthTestEnable, bool enableAlphaBlending, bool useTextures, const RenderingConfiguration &renderingConfiguration, const std::string &name="VectorRenderer", const std::string &shadersName="vector", const std::string &glyphShadersName="glyph", bool filledTriangles=false, bool useCamera=true)
 
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 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 Scene &scene, const std::shared_ptr< vireo::RenderTarget > &colorAttachment, const std::shared_ptr< vireo::RenderTarget > &depthAttachment, uint32 frameIndex)
 
void render (vireo::CommandList &commandList, const std::shared_ptr< vireo::RenderTarget > &colorAttachment, const std::shared_ptr< vireo::RenderTarget > &depthAttachment, uint32 frameIndex)
 
virtual ~VectorRenderer () = default
 
 VectorRenderer (VectorRenderer &) = delete
 
VectorRenderer & operator= (VectorRenderer &) = delete
 

Protected Member Functions

int32 addTexture (const std::shared_ptr< Image > &texture)
 
int32 addFont (const Font &font)
 

Protected Attributes

const RenderingConfigurationconfig
 
bool vertexBufferDirty {true}
 
std::vector< VertexlinesVertices
 
std::vector< VertextriangleVertices
 
std::vector< VertexglyphVertices
 

Constructor & Destructor Documentation

VectorRenderer ( bool  depthTestEnable,
bool  enableAlphaBlending,
bool  useTextures,
const RenderingConfiguration renderingConfiguration,
const std::string &  name = "VectorRenderer",
const std::string &  shadersName = "vector",
const std::string &  glyphShadersName = "glyph",
bool  filledTriangles = false,
bool  useCamera = true 
)

Constructs a vector renderer.

Parameters
depthTestEnableEnable depth test for 3D primitives.
enableAlphaBlendingEnable alpha blending (for UI/text).
useTexturesAllow textured triangles.
renderingConfigurationGlobal rendering config.
nameDebug name for pipelines.
shadersNameBase shader name for vector primitives.
glyphShadersNameBase shader name for glyph rendering.
filledTrianglesTrue to use triangle pipeline; false for wireframe only.
useCameraTrue to apply Scene view/projection.
virtual ~VectorRenderer ( )
virtualdefault
VectorRenderer ( VectorRenderer &  )
delete

Member Function Documentation

int32 addFont ( const Font font)
protected
int32 addTexture ( const std::shared_ptr< Image > &  texture)
protected
void drawLine ( const float3 &  from,
const float3 &  to,
const float4 &  color 
)

Adds a colored line segment to the current batch.

void drawText ( const std::string &  text,
Font font,
float  fontScale,
const float3 &  position,
const quaternion &  rotation,
const float4 &  innerColor 
)

Adds text to the current batch using the provided font.

Parameters
textUTF-8 string to render.
fontFont object providing glyph atlas/metrics.
fontScaleScaling factor applied to glyph metrics.
positionBaseline origin for the text in world/screen space.
rotationOrientation for the text in world space.
innerColorColor applied to glyphs (vertex alpha can modulate it).
void drawTriangle ( const float3 &  v1,
const float3 &  v2,
const float3 &  v3,
const float4 &  color 
)

Adds a filled triangle to the current batch.

VectorRenderer& operator= ( VectorRenderer &  )
delete
void render ( vireo::CommandList &  commandList,
const Scene scene,
const std::shared_ptr< vireo::RenderTarget > &  colorAttachment,
const std::shared_ptr< vireo::RenderTarget > &  depthAttachment,
uint32  frameIndex 
)

Renders accumulated primitives using the given Scene (with camera).

Parameters
commandListCommand buffer to record into.
sceneScene providing camera matrices.
colorAttachmentTarget color surface.
depthAttachmentTarget depth surface (may be null if no depth).
frameIndexIndex of the current frame in flight.
void render ( vireo::CommandList &  commandList,
const std::shared_ptr< vireo::RenderTarget > &  colorAttachment,
const std::shared_ptr< vireo::RenderTarget > &  depthAttachment,
uint32  frameIndex 
)

Renders accumulated primitives without referencing a Scene camera. Useful for UI-like overlays in screen space.

void restart ( )

Clears accumulated geometry (call once per frame).

void update ( const vireo::CommandList &  commandList,
uint32  frameIndex 
)

Uploads dirty vertex buffers and prepares descriptor sets.

Member Data Documentation

const RenderingConfiguration& config
protected
std::vector<Vertex> glyphVertices
protected
std::vector<Vertex> linesVertices
protected
std::vector<Vertex> triangleVertices
protected
bool vertexBufferDirty {true}
protected