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.
 
FLINT_API SDL_GPUPrimitiveType getSDLPrimitiveType () const
 Map the engine PrimitiveType to the corresponding SDL GPU primitive type.
 
FLINT_API 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 23 of file primitives.h.

Constructor & Destructor Documentation

◆ PrimitiveArray()

Flint::PrimitiveArray::PrimitiveArray ( PrimitiveType type)
inline

Construct a PrimitiveArray with the given topology.

Parameters
typePrimitive topology (Points, Lines, or LineStrip).

Definition at line 32 of file primitives.h.

Member Function Documentation

◆ emit()

FLINT_API void Flint::PrimitiveArray::emit ( RenderQueue & queue) const
overridevirtual

Emit this drawable's rendering work for the current frame.

Called once after submitted drawables have been sorted by DrawLayer. Implementations must enqueue work through queue rather than issuing immediate GPU commands.

Parameters
queueQueue receiving this drawable's rendering work.

Implements Flint::Drawable.

◆ getSDLPrimitiveType()

FLINT_API SDL_GPUPrimitiveType Flint::PrimitiveArray::getSDLPrimitiveType ( ) const

Map the engine PrimitiveType to the corresponding SDL GPU primitive type.

Returns
SDL_GPUPrimitiveType suitable for pipeline binding.

◆ getTransformedData()

const void * Flint::PrimitiveArray::getTransformedData ( ) const
inline

Return a pointer to the most recently transformed vertex data.

Valid after the last call to draw().

Definition at line 102 of file primitives.h.

◆ getTransformedSize()

size_t Flint::PrimitiveArray::getTransformedSize ( ) const
inline

Return the byte size of the transformed vertex buffer.

Definition at line 109 of file primitives.h.

◆ getVertexCount()

size_t Flint::PrimitiveArray::getVertexCount ( ) const
inline

Return the number of transformed vertices ready for upload.

Definition at line 116 of file primitives.h.

◆ init()

void Flint::PrimitiveArray::init ( SDL_GPUDevice * device)
inline

Associate a GPU device (required before draw() is called by the renderer).

Parameters
deviceSDL GPU device.

Definition at line 52 of file primitives.h.

◆ operator[]() [1/2]

PrimitiveVertex & Flint::PrimitiveArray::operator[] ( std::size_t i)
inline

Non-const element access.

Definition at line 75 of file primitives.h.

◆ operator[]() [2/2]

const PrimitiveVertex & Flint::PrimitiveArray::operator[] ( std::size_t i) const
inline

Const element access.

Definition at line 80 of file primitives.h.

◆ resize()

void Flint::PrimitiveArray::resize ( std::size_t count)
inline

Resize the vertex array to count entries.

New entries are value-initialized.

Parameters
countDesired number of vertices.

Definition at line 63 of file primitives.h.

◆ setPrimitiveType()

void Flint::PrimitiveArray::setPrimitiveType ( PrimitiveType type)
inline

Change the primitive topology.

Parameters
typeNew topology.

Definition at line 43 of file primitives.h.

◆ size()

std::size_t Flint::PrimitiveArray::size ( ) const
inline

Return the current number of vertices.

Definition at line 70 of file primitives.h.


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