Raftel Engine
 
Loading...
Searching...
No Matches
Raftel::Shape Class Reference

Represents a 2D shape made up of vertices that can be rendered to the screen. More...

#include <shape.hpp>

Public Member Functions

 Shape (const std::vector< float > &vertices)
 Construct a new Shape object with the given vertices.
 
void draw ()
 Renders the shape to the screen.
 
 ~Shape ()
 Destroy the Shape object and release OpenGL resources.
 

Public Attributes

Transform2D tr
 The 2D transformation applied to the shape.
 

Detailed Description

Represents a 2D shape made up of vertices that can be rendered to the screen.

This class is responsible for handling the vertex data of the shape, setting up the OpenGL buffers (VAO and VBO), and providing a function to render the shape to the screen. It also includes a Transform2D member, which can be used to apply transformations (e.g., translation, scaling, and rotation) to the shape.

Definition at line 38 of file shape.hpp.

Constructor & Destructor Documentation

◆ Shape()

Raftel::Shape::Shape ( const std::vector< float > & vertices)

Construct a new Shape object with the given vertices.

Initializes the shape with the provided vertex data and sets up the necessary OpenGL buffers (VAO, VBO) for rendering.

Parameters
verticesA vector of floats representing the vertex data of the shape.

◆ ~Shape()

Raftel::Shape::~Shape ( )

Destroy the Shape object and release OpenGL resources.

Deletes the OpenGL Vertex Array Object (VAO) and Vertex Buffer Object (VBO) associated with the shape to free resources when the object is destroyed.

Member Function Documentation

◆ draw()

void Raftel::Shape::draw ( )

Renders the shape to the screen.

This function binds the shape's VAO and draws the shape to the screen using the stored vertex data. It also applies the transformation before drawing and resets it afterward.

Member Data Documentation

◆ tr

Transform2D Raftel::Shape::tr

The 2D transformation applied to the shape.

Definition at line 68 of file shape.hpp.


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