|
Flint Engine
Modular C++20 2D game engine powered by SDL3
|
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. | |
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.
|
inline |
Construct a PrimitiveArray with the given topology.
| type | Primitive topology (Points, Lines, or LineStrip). |
Definition at line 32 of file primitives.h.
|
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.
| queue | Queue receiving this drawable's rendering work. |
Implements Flint::Drawable.
| FLINT_API SDL_GPUPrimitiveType Flint::PrimitiveArray::getSDLPrimitiveType | ( | ) | const |
Map the engine PrimitiveType to the corresponding SDL GPU primitive type.
|
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.
|
inline |
Return the byte size of the transformed vertex buffer.
Definition at line 109 of file primitives.h.
|
inline |
Return the number of transformed vertices ready for upload.
Definition at line 116 of file primitives.h.
|
inline |
Associate a GPU device (required before draw() is called by the renderer).
| device | SDL GPU device. |
Definition at line 52 of file primitives.h.
|
inline |
Non-const element access.
Definition at line 75 of file primitives.h.
|
inline |
Const element access.
Definition at line 80 of file primitives.h.
|
inline |
Resize the vertex array to count entries.
New entries are value-initialized.
| count | Desired number of vertices. |
Definition at line 63 of file primitives.h.
|
inline |
Change the primitive topology.
| type | New topology. |
Definition at line 43 of file primitives.h.
|
inline |
Return the current number of vertices.
Definition at line 70 of file primitives.h.