Shape¶
High-level shape handling utilities.
Overview¶
Typical use cases:
Handling 2D shape definitions and vertex data retrieval.
TODO:
Connect shape to GPU buffers for rendering.
Header¶
<RaeptorCogs/Shape.hpp>
Metadata¶
- Author
Estorc
- Version
v1.0
- Copyright
Copyright (c) 2025 Estorc MIT License.
Classes¶
Class |
Description |
|---|---|
|
Quad shape class. |
|
Regular polygon shape class. |
|
Base Shape class. |
-
class Quad : public RaeptorCogs::Shape¶
Quad shape class.
Provides vertex and index data for a simple quad shape.
std::shared_ptr<Shape> quad = std::make_shared<Quad>(); size_t triangleCount; const float* vertices = quad->getVertices(); const unsigned* indices = quad->getIndices(triangleCount);
Public Functions
-
inline virtual const float *getVertices() const override¶
Get vertex data.
- Returns:
Pointer to the vertex array.
Private Static Attributes
-
static float vertices[] = {0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f}¶
Vertex data for the quad.
Each vertex consists of position (x, y) and UV coordinates (u, v).
Note
The quad is defined in a 1x1 space from (0,0) to (1,1).
-
static unsigned indices[] = {0, 1, 2, 2, 3, 0}¶
Index data for the quad.
Defines two triangles that make up the quad.
-
inline virtual const float *getVertices() const override¶
-
class RegularPolygon : public RaeptorCogs::Shape¶
Regular polygon shape class.
Provides vertex and index data for a regular polygon shape with a specified number of sides.
Public Functions
-
~RegularPolygon() override = default¶
Destructor for RegularPolygon.
-
inline RegularPolygon(unsigned int sides)¶
Constructor for RegularPolygon.
- Parameters:
sides – Number of sides of the polygon.
-
inline virtual const float *getVertices() const override¶
Get vertex data.
- Returns:
Pointer to the vertex array.
Private Functions
-
inline void generateGeometry()¶
Generate geometry for the polygon.
Note
Called during construction to populate vertices and indices.
-
~RegularPolygon() override = default¶
-
class Shape¶
Base Shape class.
Provides an interface for 2D shapes to retrieve vertex and index data.
Subclassed by RaeptorCogs::Quad, RaeptorCogs::RegularPolygon
Public Functions
-
virtual ~Shape() = default¶
Virtual destructor.
-
virtual void getVertexData(std::vector<glm::mat3> *outTrianglesPos, std::vector<glm::mat3x2> *outTrianglesUV, size_t *triangleCount) const¶
Get vertex data as triangles.
Note
The default implementation converts the shape’s vertices and indices into triangles.
- Parameters:
outTrianglesPos – Output vector for triangle positions.
outTrianglesUV – Output vector for triangle UV coordinates.
triangleCount – Output number of triangles.
-
virtual const float *getVertices() const = 0¶
Get raw vertex array.
- Returns:
Pointer to the vertex array.
-
virtual ~Shape() = default¶