Flint Engine
Modular C++20 2D game engine powered by SDL3
Loading...
Searching...
No Matches
Flint::PrimitiveArray Class Reference

A CPU-side collection of colored 2-D vertices that can be drawn as primitives. More...

#include <flint/graphics/primitives.h>

+ Inheritance diagram for Flint::PrimitiveArray:
+ Collaboration diagram for Flint::PrimitiveArray:

Public Member Functions

 PrimitiveArray (PrimitiveType type)
 Construct a PrimitiveArray with the given topology.
 
void setPrimitiveType (PrimitiveType type)
 Change the primitive topology.
 
void init (SDL_GPUDevice *device)
 Associate a GPU device (required before draw() is called by the renderer).
 
void resize (std::size_t count)
 Resize the vertex array to count entries.
 
std::size_t size () const
 Return the current number of vertices.
 
PrimitiveVertex & operator[] (std::size_t i)
 Non-const element access.
 
const PrimitiveVertex & operator[] (std::size_t i) const
 Const element access.
 
SDL_GPUPrimitiveType getSDLPrimitiveType () const
 Map the engine PrimitiveType to the corresponding SDL GPU primitive type.
 
void emit (RenderQueue &queue) const override
 Emit this drawable's rendering work for the current frame.
 
const void * getTransformedData () const
 Return a pointer to the most recently transformed vertex data.
 
size_t getTransformedSize () const
 Return the byte size of the transformed vertex buffer.
 
size_t getVertexCount () const
 Return the number of transformed vertices ready for upload.
 
- Public Member Functions inherited from Flint::Drawable
void setGPUTexture (GPUTexture *texture)
 Associate a texture with this drawable.
 
GPUTexture * getGPUTexture () const
 Get the associated GPU texture.
 

Additional Inherited Members

- Protected Attributes inherited from Flint::Drawable
GPUTexture * m_gpuTexture = nullptr
 Non-owning reference to the GPU texture asset.
 

Detailed Description

A CPU-side collection of colored 2-D vertices that can be drawn as primitives.

Vertices are specified in world space. On draw(), they are transformed to NDC using the supplied camera view rect and cached in a GPU-ready format. The PrimitivePipeline is responsible for uploading the transformed data and selecting the correct primitive type.

Definition at line 22 of file primitives.h.


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