3D Graphics Engine for ESP32
 
Loading...
Searching...
No Matches
Ragot::FrameBuffer< Color > Class Template Reference

Class to manage a frame buffer for rendering graphics. More...

#include <FrameBuffer.hpp>

Inheritance diagram for Ragot::FrameBuffer< Color >:
Inheritance graph
Collaboration diagram for Ragot::FrameBuffer< Color >:
Collaboration graph

Public Types

using TYPE = Color
 
using ColorVector = std::vector < Color >
 

Public Member Functions

 FrameBuffer (size_t width, size_t height, bool double_buffer)
 Constructor for the FrameBuffer class.
 
 FrameBuffer ()=delete
 Default constructor for the FrameBuffer class (Deleted).
 
 ~FrameBuffer ()=default
 Default destructor for the FrameBuffer class.
 
 FrameBuffer (const FrameBuffer &)=delete
 Construct a new Frame Buffer object (Deleted).
 
 FrameBuffer (const FrameBuffer &&)=delete
 Construct a new Frame Buffer object (Deleted).
 
FrameBufferoperator= (const FrameBuffer &)=delete
 Assignment operator for the FrameBuffer class (Deleted).
 
FrameBufferoperator= (const FrameBuffer &&)=delete
 Assignment operator for the FrameBuffer class (Deleted).
 
void swap_buffers ()
 Swaps the current buffer with the next buffer.
 
void clear_buffer (Buffer buffer_to_clear=NEXT_BUFFER)
 Clears the specified buffer by filling it with the default color.
 
void fill (Color color=0, Buffer buffer_to_fill=NEXT_BUFFER)
 Fills the specified buffer with the given color.
 
void set_pixel (size_t x, size_t y, Color color)
 Sets a pixel at the specified coordinates to the given color.
 
void set_pixel (size_t offset, Color color)
 Sets a pixel at the specified offset in the buffer to the given color.
 
void set_pixel (size_t offset)
 Sets a pixel at the specified offset in the buffer to the default color.
 
void set_color (Color color)
 Sets the default color for the frame buffer.
 
Color get_pixel (size_t x, size_t y) const
 Gets the color of a pixel at the specified coordinates.
 
size_t get_width ()
 Gets the color of a pixel at the specified offset in the buffer.
 
size_t get_width () const
 Gets the width of the frame buffer.
 
size_t get_height ()
 Gets the height of the frame buffer.
 
size_t get_height () const
 Gets the height of the frame buffer.
 
const Color * get_buffer () const
 Gets the current buffer being used.
 
Color * get_buffer ()
 Get the buffer object.
 
void blit_to_window () const
 Blits the current buffer to the window. This method copies the contents of the current buffer to the next buffer, effectively preparing the next frame for rendering.
 
void initGLTexture ()
 Initializes the OpenGL texture for the frame buffer.
 
void sendGL () const
 Clears the OpenGL texture associated with the frame buffer.
 
GLuint getGLTex () const
 Gets the OpenGL texture ID for the frame buffer.
 

Static Public Member Functions

static GLenum getGLFormat ()
 Sets the OpenGL texture for the frame buffer.
 
static GLenum getGLType ()
 Gets the OpenGL type for the frame buffer.
 

Private Attributes

bool double_buffer
 Flag to indicate if double buffering is enabled.
 
size_t width
 Width of the frame buffer in pixels.
 
size_t height
 Height of the frame buffer in pixels.
 
Color color
 Default color for filling the buffer.
 
ColorVector buffer_1
 First buffer for single or double buffering.
 
ColorVector buffer_2
 Second buffer for double buffering (if enabled)
 
ColorVectorcurrent_buffer
 Pointer to the current buffer being used.
 
ColorVectornext_buffer
 Pointer to the next buffer to be used (for double buffering)
 
GLuint gl_tex = 0
 OpenGL texture ID for the frame buffer.
 

Detailed Description

template<typename Color>
class Ragot::FrameBuffer< Color >

Class to manage a frame buffer for rendering graphics.

This class provides methods to create a frame buffer, swap buffers, clear the buffer, fill it with a color, set and get pixels, and manage OpenGL textures. It supports both single and double buffering modes.

Member Typedef Documentation

◆ ColorVector

template<typename Color>
using Ragot::FrameBuffer< Color >::ColorVector = std::vector < Color >

◆ TYPE

template<typename Color>
using Ragot::FrameBuffer< Color >::TYPE = Color

Constructor & Destructor Documentation

◆ FrameBuffer() [1/4]

template<typename Color>
Ragot::FrameBuffer< Color >::FrameBuffer ( size_t width,
size_t height,
bool double_buffer )

Constructor for the FrameBuffer class.

Initializes the frame buffer with the specified width, height, and double buffering option. Allocates memory for the buffers and fills them with the default color.

Parameters
widthWidth of the frame buffer in pixels.
heightHeight of the frame buffer in pixels.
double_bufferFlag to indicate if double buffering is enabled.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FrameBuffer() [2/4]

template<typename Color>
Ragot::FrameBuffer< Color >::FrameBuffer ( )
delete

Default constructor for the FrameBuffer class (Deleted).

◆ ~FrameBuffer()

template<typename Color>
Ragot::FrameBuffer< Color >::~FrameBuffer ( )
default

Default destructor for the FrameBuffer class.

Cleans up resources used by the frame buffer.

◆ FrameBuffer() [3/4]

template<typename Color>
Ragot::FrameBuffer< Color >::FrameBuffer ( const FrameBuffer< Color > & )
delete

Construct a new Frame Buffer object (Deleted).

Here is the call graph for this function:

◆ FrameBuffer() [4/4]

template<typename Color>
Ragot::FrameBuffer< Color >::FrameBuffer ( const FrameBuffer< Color > && )
delete

Construct a new Frame Buffer object (Deleted).

Here is the call graph for this function:

Member Function Documentation

◆ blit_to_window()

template<typename Color>
void Ragot::FrameBuffer< Color >::blit_to_window ( ) const
inline

Blits the current buffer to the window. This method copies the contents of the current buffer to the next buffer, effectively preparing the next frame for rendering.

◆ clear_buffer()

template<typename Color>
void Ragot::FrameBuffer< Color >::clear_buffer ( Buffer buffer_to_clear = NEXT_BUFFER)

Clears the specified buffer by filling it with the default color.

Parameters
buffer_to_clearThe buffer to clear (CURRENT_BUFFER, NEXT_BUFFER, or MAX_BUFFER).
Here is the call graph for this function:

◆ fill()

template<typename Color>
void Ragot::FrameBuffer< Color >::fill ( Color color = 0,
Buffer buffer_to_fill = NEXT_BUFFER )

Fills the specified buffer with the given color.

Parameters
colorThe color to fill the buffer with (default is 0).
buffer_to_fillThe buffer to fill (CURRENT_BUFFER, NEXT_BUFFER, or MAX_BUFFER).
Here is the caller graph for this function:

◆ get_buffer() [1/2]

template<typename Color>
Color * Ragot::FrameBuffer< Color >::get_buffer ( )
inline

Get the buffer object.

Returns
Color*

◆ get_buffer() [2/2]

template<typename Color>
const Color * Ragot::FrameBuffer< Color >::get_buffer ( ) const
inline

Gets the current buffer being used.

Returns
const Color* Pointer to the current buffer data.

◆ get_height() [1/2]

template<typename Color>
size_t Ragot::FrameBuffer< Color >::get_height ( )
inline

Gets the height of the frame buffer.

Returns
size_t The height of the frame buffer in pixels.

◆ get_height() [2/2]

template<typename Color>
size_t Ragot::FrameBuffer< Color >::get_height ( ) const
inline

Gets the height of the frame buffer.

Returns
size_t The height of the frame buffer in pixels.

◆ get_pixel()

template<typename Color>
Color Ragot::FrameBuffer< Color >::get_pixel ( size_t x,
size_t y ) const

Gets the color of a pixel at the specified coordinates.

Parameters
xX coordinate of the pixel.
yY coordinate of the pixel.
Returns
Color The color of the pixel at the specified coordinates.

◆ get_width() [1/2]

template<typename Color>
size_t Ragot::FrameBuffer< Color >::get_width ( )
inline

Gets the color of a pixel at the specified offset in the buffer.

Parameters
offsetOffset in the buffer (calculated as y * width + x).
Returns
Color The color of the pixel at the specified offset.

◆ get_width() [2/2]

template<typename Color>
size_t Ragot::FrameBuffer< Color >::get_width ( ) const
inline

Gets the width of the frame buffer.

Returns
size_t The width of the frame buffer in pixels.

◆ getGLFormat()

template<typename Color>
GLenum Ragot::FrameBuffer< Color >::getGLFormat ( )
static

Sets the OpenGL texture for the frame buffer.

This method binds the OpenGL texture to the current context.

◆ getGLTex()

template<typename Color>
GLuint Ragot::FrameBuffer< Color >::getGLTex ( ) const
inline

Gets the OpenGL texture ID for the frame buffer.

Returns
GLuint The OpenGL texture ID.

◆ getGLType()

template<typename Color>
GLenum Ragot::FrameBuffer< Color >::getGLType ( )
static

Gets the OpenGL type for the frame buffer.

This method returns the OpenGL type corresponding to the color format used in the frame buffer.

Returns
GLenum The OpenGL type for the frame buffer.

◆ initGLTexture()

template<typename Color>
void Ragot::FrameBuffer< Color >::initGLTexture ( )

Initializes the OpenGL texture for the frame buffer.

This method creates an OpenGL texture and binds it to the frame buffer.

Here is the caller graph for this function:

◆ operator=() [1/2]

template<typename Color>
FrameBuffer & Ragot::FrameBuffer< Color >::operator= ( const FrameBuffer< Color > && )
delete

Assignment operator for the FrameBuffer class (Deleted).

Prevents assignment of FrameBuffer objects.

Returns
FrameBuffer& Reference to the current object.
Here is the call graph for this function:

◆ operator=() [2/2]

template<typename Color>
FrameBuffer & Ragot::FrameBuffer< Color >::operator= ( const FrameBuffer< Color > & )
delete

Assignment operator for the FrameBuffer class (Deleted).

Prevents assignment of FrameBuffer objects.

Returns
FrameBuffer& Reference to the current object.
Here is the call graph for this function:

◆ sendGL()

template<typename Color>
void Ragot::FrameBuffer< Color >::sendGL ( ) const

Clears the OpenGL texture associated with the frame buffer.

This method deletes the OpenGL texture to free up resources.

◆ set_color()

template<typename Color>
void Ragot::FrameBuffer< Color >::set_color ( Color color)

Sets the default color for the frame buffer.

Parameters
colorThe color to set as the default.

◆ set_pixel() [1/3]

template<typename Color>
void Ragot::FrameBuffer< Color >::set_pixel ( size_t offset)

Sets a pixel at the specified offset in the buffer to the default color.

Parameters
offsetOffset in the buffer (calculated as y * width + x).

◆ set_pixel() [2/3]

template<typename Color>
void Ragot::FrameBuffer< Color >::set_pixel ( size_t offset,
Color color )

Sets a pixel at the specified offset in the buffer to the given color.

Parameters
offsetOffset in the buffer (calculated as y * width + x).
colorColor value for the pixel.

◆ set_pixel() [3/3]

template<typename Color>
void Ragot::FrameBuffer< Color >::set_pixel ( size_t x,
size_t y,
Color color )

Sets a pixel at the specified coordinates to the given color.

Parameters
xX coordinate of the pixel.
yY coordinate of the pixel.
colorColor value for the pixel.

◆ swap_buffers()

template<typename Color>
void Ragot::FrameBuffer< Color >::swap_buffers ( )

Swaps the current buffer with the next buffer.

This method is used in double buffering to switch between the buffers for rendering.

Member Data Documentation

◆ buffer_1

template<typename Color>
ColorVector Ragot::FrameBuffer< Color >::buffer_1
private

First buffer for single or double buffering.

◆ buffer_2

template<typename Color>
ColorVector Ragot::FrameBuffer< Color >::buffer_2
private

Second buffer for double buffering (if enabled)

◆ color

template<typename Color>
Color Ragot::FrameBuffer< Color >::color
private

Default color for filling the buffer.

◆ current_buffer

template<typename Color>
ColorVector* Ragot::FrameBuffer< Color >::current_buffer
private

Pointer to the current buffer being used.

◆ double_buffer

template<typename Color>
bool Ragot::FrameBuffer< Color >::double_buffer
private

Flag to indicate if double buffering is enabled.

◆ gl_tex

template<typename Color>
GLuint Ragot::FrameBuffer< Color >::gl_tex = 0
private

OpenGL texture ID for the frame buffer.

This variable holds the OpenGL texture ID used for rendering the frame buffer.

◆ height

template<typename Color>
size_t Ragot::FrameBuffer< Color >::height
private

Height of the frame buffer in pixels.

◆ next_buffer

template<typename Color>
ColorVector* Ragot::FrameBuffer< Color >::next_buffer
private

Pointer to the next buffer to be used (for double buffering)

◆ width

template<typename Color>
size_t Ragot::FrameBuffer< Color >::width
private

Width of the frame buffer in pixels.


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