Lysa  0.0
Lysa 3D Engine
Vector3DRenderer Class Reference

Detailed Description

Immediate-style 3D vector renderer

  • 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.
  • Call restart() between frames to clear accumulated geometry.
  • Thread-safety: calls are expected from the render thread only.
+ Inheritance diagram for Vector3DRenderer:

Classes

struct  Vertex
 

Public Member Functions

 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
 

Protected Member Functions

int32 addTexture (const Image &texture)
 
int32 addFont (const Font &font)
 

Protected Attributes

ImageManagerimageManager
 
const RendererConfigurationconfig
 
bool vertexBufferDirty {true}
 
std::vector< VertexlinesVertices
 
std::vector< VertextriangleVertices
 
std::vector< VerteximagesVertices
 
std::vector< VertexglyphVertices
 

Constructor & Destructor Documentation

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" 
)

Constructs a vector renderer.

Parameters
configRendering config.
outputFormat
useCameraTrue to apply Scene view/projection.
depthTestEnableEnable depth test for 3D primitives.
enableAlphaBlendingEnable alpha blending (for UI/text).
filledTrianglesTrue to fill the triangles; false for wireframe only.
nameDebug name for pipelines.
shadersNameBase shader name for vector primitives.
glyphShadersNameBase shader name for glyph rendering.
virtual ~Vector3DRenderer ( )
virtualdefault
Vector3DRenderer ( Vector3DRenderer &  )
delete

Member Function Documentation

int32 addFont ( const Font font)
protected
int32 addTexture ( const Image texture)
protected
void drawImage ( unique_id  image,
const float3 &  position,
const quaternion &  rotation,
const float2 &  size,
const float4 &  color 
)
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.

bool isUseCamera ( ) const
inline
Vector3DRenderer& operator= ( Vector3DRenderer &  )
delete
void render ( vireo::CommandList &  commandList,
const Camera camera,
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.
cameraCurrent camera (ignored if useCamera is false)
colorAttachmentTarget color surface.
depthAttachmentTarget depth surface (may be null if no depth).
frameIndexIndex of the current frame in flight.
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 RendererConfiguration& config
protected
std::vector<Vertex> glyphVertices
protected
ImageManager& imageManager
protected
std::vector<Vertex> imagesVertices
protected
std::vector<Vertex> linesVertices
protected
std::vector<Vertex> triangleVertices
protected
bool vertexBufferDirty {true}
protected