4#include "flint/core/api.h"
5#include "flint/graphics/drawable.h"
6#include "flint/graphics/renderer.h"
7#include "flint/graphics/types/color.h"
8#include "flint/graphics/types/primitive-types.h"
9#include "flint/math/types.h"
52 void init(SDL_GPUDevice *device) {
64 m_vertices.resize(count);
71 return m_vertices.size();
103 return m_transformedVerts.data();
110 return m_transformedVerts.size() *
sizeof(GPULineVertex);
117 return m_transformedVerts.size();
129 PrimitiveType m_type;
130 std::vector<PrimitiveVertex> m_vertices;
131 SDL_GPUDevice *m_device =
nullptr;
133 mutable std::vector<GPULineVertex> m_transformedVerts;
135 mutable SDL_GPUBuffer *m_vertexBuffer =
nullptr;
136 mutable Uint32 m_vertexBufferSize = 0;
Interface for objects that contribute ordered work to a rendered frame.
A CPU-side collection of colored 2-D vertices that can be drawn as primitives.
void setPrimitiveType(PrimitiveType type)
Change the primitive topology.
size_t getVertexCount() const
Return the number of transformed vertices ready for upload.
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 PrimitiveVertex & operator[](std::size_t i) const
Const element access.
std::size_t size() const
Return the current number of vertices.
PrimitiveArray(PrimitiveType type)
Construct a PrimitiveArray with the given topology.
PrimitiveVertex & operator[](std::size_t i)
Non-const element access.
void resize(std::size_t count)
Resize the vertex array to count entries.
size_t getTransformedSize() const
Return the byte size of the transformed vertex buffer.
void init(SDL_GPUDevice *device)
Associate a GPU device (required before draw() is called by the renderer).
const void * getTransformedData() const
Return a pointer to the most recently transformed vertex data.
Batches drawables into sorted geometry, primitive, and custom execution passes for GPURenderer.
Internal vertex structure sent directly to line/point primitive shaders.
Public user-facing vertex representation for point and line primitives.