galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
galaxy::graphics::Framebuffer Class Referencefinal

OpenGL framebuffer to render to. More...

#include <Framebuffer.hpp>

+ Collaboration diagram for galaxy::graphics::Framebuffer:

Public Member Functions

 Framebuffer ()
 Constructor.
 
 Framebuffer (Framebuffer &&)
 Move constructor.
 
Framebufferoperator= (Framebuffer &&)
 Move assignment operator.
 
 ~Framebuffer ()
 Destructor.
 
void add_colour_attachment (const int width, const int height)
 Add a colour attachment to the framebuffer.
 
void add_depth_stencil_renderbuffer ()
 Adds a depth and stencil supported renderbuffer to the framebuffer.
 
void add_storage_attachment ()
 Add an attachment to store an integer.
 
void create ()
 Construct framebuffer from attachments and renderbuffers.
 
int read_storagebuffer (const int x, const int y)
 Read storage buffer.
 
void clear_storagebuffer (const int val)
 Clear storagebuffer.
 
void set_clear_colour (const graphics::Colour &col)
 Set clear colour.
 
void begin (const bool clear=true)
 Bind framebuffer for rendering to.
 
void end ()
 Unbind framebuffer.
 
void clear ()
 Clear framebuffer attachments.
 
void clear (const unsigned int index)
 Clear a specific attachment.
 
void reset ()
 Completely delete objects.
 
int width () const
 Get width.
 
int height () const
 Get height.
 
unsigned int texture () const
 Get colour attachment texture id.
 
unsigned int id () const
 Get OpenGL framebuffer object.
 

Private Member Functions

 Framebuffer (const Framebuffer &)=delete
 Copy constructor.
 
Framebufferoperator= (const Framebuffer &)=delete
 Copy assignment operator.
 

Private Attributes

unsigned int m_id
 OpenGL handle.
 
int m_width
 Width cache.
 
int m_height
 Height cache.
 
unsigned int m_colour
 Colour attachment id.
 
unsigned int m_renderbuffer
 Renderbuffer attachment.
 
unsigned int m_storageattach
 Storage attachment id.
 
std::array< float, 4 > m_clear_colour
 Clear colour.
 

Detailed Description

OpenGL framebuffer to render to.

Definition at line 20 of file Framebuffer.hpp.

Constructor & Destructor Documentation

◆ Framebuffer() [1/3]

galaxy::graphics::Framebuffer::Framebuffer ( )

Constructor.

Definition at line 18 of file Framebuffer.cpp.

◆ Framebuffer() [2/3]

galaxy::graphics::Framebuffer::Framebuffer ( Framebuffer && f)

Move constructor.

Definition at line 30 of file Framebuffer.cpp.

◆ ~Framebuffer()

galaxy::graphics::Framebuffer::~Framebuffer ( )

Destructor.

Definition at line 107 of file Framebuffer.cpp.

◆ Framebuffer() [3/3]

galaxy::graphics::Framebuffer::Framebuffer ( const Framebuffer & )
privatedelete

Copy constructor.

Member Function Documentation

◆ operator=() [1/2]

Framebuffer & galaxy::graphics::Framebuffer::operator= ( Framebuffer && f)

Move assignment operator.

Definition at line 66 of file Framebuffer.cpp.

◆ add_colour_attachment()

void galaxy::graphics::Framebuffer::add_colour_attachment ( const int width,
const int height )

Add a colour attachment to the framebuffer.

Parameters
widthUsually screen width or size of render texture.
heightUsually screen height or size of render texture.

Definition at line 130 of file Framebuffer.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ add_depth_stencil_renderbuffer()

void galaxy::graphics::Framebuffer::add_depth_stencil_renderbuffer ( )

Adds a depth and stencil supported renderbuffer to the framebuffer.

Definition at line 158 of file Framebuffer.cpp.

+ Here is the caller graph for this function:

◆ add_storage_attachment()

void galaxy::graphics::Framebuffer::add_storage_attachment ( )

Add an attachment to store an integer.

Definition at line 179 of file Framebuffer.cpp.

◆ create()

void galaxy::graphics::Framebuffer::create ( )

Construct framebuffer from attachments and renderbuffers.

Definition at line 204 of file Framebuffer.cpp.

+ Here is the caller graph for this function:

◆ read_storagebuffer()

int galaxy::graphics::Framebuffer::read_storagebuffer ( const int x,
const int y )
nodiscard

Read storage buffer.

Parameters
xHorizontal pixel pos.
yVertical pixel pos.
Returns
Integer read at pixel coords.

Definition at line 259 of file Framebuffer.cpp.

◆ clear_storagebuffer()

void galaxy::graphics::Framebuffer::clear_storagebuffer ( const int val)

Clear storagebuffer.

Parameters
valValue to clear buffer to.

Definition at line 274 of file Framebuffer.cpp.

◆ set_clear_colour()

void galaxy::graphics::Framebuffer::set_clear_colour ( const graphics::Colour & col)

Set clear colour.

Parameters
colColour to clear framebuffer to.

Definition at line 279 of file Framebuffer.cpp.

+ Here is the call graph for this function:

◆ begin()

void galaxy::graphics::Framebuffer::begin ( const bool clear = true)

Bind framebuffer for rendering to.

Parameters
clearShould the framebuffer clear attachments.

Definition at line 289 of file Framebuffer.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ end()

void galaxy::graphics::Framebuffer::end ( )

Unbind framebuffer.

Definition at line 301 of file Framebuffer.cpp.

+ Here is the caller graph for this function:

◆ clear() [1/2]

void galaxy::graphics::Framebuffer::clear ( )

Clear framebuffer attachments.

Definition at line 306 of file Framebuffer.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ clear() [2/2]

void galaxy::graphics::Framebuffer::clear ( const unsigned int index)

Clear a specific attachment.

Parameters
indexSpecific index of attachment to clear.

Definition at line 325 of file Framebuffer.cpp.

◆ reset()

void galaxy::graphics::Framebuffer::reset ( )

Completely delete objects.

Definition at line 330 of file Framebuffer.cpp.

+ Here is the caller graph for this function:

◆ width()

int galaxy::graphics::Framebuffer::width ( ) const
nodiscard

Get width.

Returns
Integer.

Definition at line 352 of file Framebuffer.cpp.

+ Here is the caller graph for this function:

◆ height()

int galaxy::graphics::Framebuffer::height ( ) const
nodiscard

Get height.

Returns
Integer.

Definition at line 357 of file Framebuffer.cpp.

+ Here is the caller graph for this function:

◆ texture()

unsigned int galaxy::graphics::Framebuffer::texture ( ) const
nodiscard

Get colour attachment texture id.

Returns
Unsigned int.

Definition at line 362 of file Framebuffer.cpp.

+ Here is the caller graph for this function:

◆ id()

unsigned int galaxy::graphics::Framebuffer::id ( ) const
nodiscard

Get OpenGL framebuffer object.

Returns
Unsigned int.

Definition at line 367 of file Framebuffer.cpp.

◆ operator=() [2/2]

Framebuffer & galaxy::graphics::Framebuffer::operator= ( const Framebuffer & )
privatedelete

Copy assignment operator.

Member Data Documentation

◆ m_id

unsigned int galaxy::graphics::Framebuffer::m_id
private

OpenGL handle.

Definition at line 167 of file Framebuffer.hpp.

◆ m_width

int galaxy::graphics::Framebuffer::m_width
private

Width cache.

Definition at line 172 of file Framebuffer.hpp.

◆ m_height

int galaxy::graphics::Framebuffer::m_height
private

Height cache.

Definition at line 177 of file Framebuffer.hpp.

◆ m_colour

unsigned int galaxy::graphics::Framebuffer::m_colour
private

Colour attachment id.

Definition at line 182 of file Framebuffer.hpp.

◆ m_renderbuffer

unsigned int galaxy::graphics::Framebuffer::m_renderbuffer
private

Renderbuffer attachment.

Definition at line 187 of file Framebuffer.hpp.

◆ m_storageattach

unsigned int galaxy::graphics::Framebuffer::m_storageattach
private

Storage attachment id.

Definition at line 192 of file Framebuffer.hpp.

◆ m_clear_colour

std::array<float, 4> galaxy::graphics::Framebuffer::m_clear_colour
private

Clear colour.

Definition at line 197 of file Framebuffer.hpp.


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