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::RenderTexture Class Referencefinal

Draw to an opengl texture instead of the screen. More...

#include <RenderTexture.hpp>

+ Collaboration diagram for galaxy::graphics::RenderTexture:

Public Member Functions

 RenderTexture ()
 Constructor.
 
 RenderTexture (RenderTexture &&)
 Move constructor.
 
RenderTextureoperator= (RenderTexture &&)
 Move assignment operator.
 
virtual ~RenderTexture ()
 Destructor.
 
void create (const int width, const int height)
 Create framebuffer and texture.
 
void recreate (const int width=-1, const int height=-1)
 Destroy and re-create framebuffer.
 
void save (std::string_view file)
 Saves texture to file on disk.
 
void bind (bool clear=true)
 Activate context.
 
void unbind ()
 Deactivate context.
 
void clear ()
 Clear framebuffer attachments.
 
int width () const
 Get texture width.
 
int height () const
 Get texture height.
 
unsigned int texture () const
 Gets framebuffer texture.
 
const glm::mat4 & get_proj ()
 Get render texture projection.
 
Framebufferfbo ()
 Get framebuffer.
 

Private Member Functions

 RenderTexture (const RenderTexture &)=delete
 Copy constructor.
 
RenderTextureoperator= (const RenderTexture &)=delete
 Copy assignment operator.
 

Private Attributes

int m_width
 Cached width.
 
int m_height
 Cached height.
 
Framebuffer m_framebuffer
 OpenGL framebuffer abstraction.
 
glm::mat4 m_proj
 Projection.
 

Detailed Description

Draw to an opengl texture instead of the screen.

Definition at line 24 of file RenderTexture.hpp.

Constructor & Destructor Documentation

◆ RenderTexture() [1/3]

galaxy::graphics::RenderTexture::RenderTexture ( )

Constructor.

Definition at line 27 of file RenderTexture.cpp.

◆ RenderTexture() [2/3]

galaxy::graphics::RenderTexture::RenderTexture ( RenderTexture && rt)

Move constructor.

Definition at line 33 of file RenderTexture.cpp.

◆ ~RenderTexture()

galaxy::graphics::RenderTexture::~RenderTexture ( )
virtual

Destructor.

Definition at line 52 of file RenderTexture.cpp.

◆ RenderTexture() [3/3]

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

Copy constructor.

Member Function Documentation

◆ operator=() [1/2]

RenderTexture & galaxy::graphics::RenderTexture::operator= ( RenderTexture && rt)

Move assignment operator.

Definition at line 40 of file RenderTexture.cpp.

◆ create()

void galaxy::graphics::RenderTexture::create ( const int width,
const int height )

Create framebuffer and texture.

Parameters
widthWidth of the render target. Must be greater than 0.
heightHeight of the render target. Must be greater than 0.

Definition at line 56 of file RenderTexture.cpp.

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

◆ recreate()

void galaxy::graphics::RenderTexture::recreate ( const int width = -1,
const int height = -1 )

Destroy and re-create framebuffer.

You will need to mark it bindless again.

Parameters
widthOptional. Will use existing size otherwise. Width of the render target. Must be greater than 0.
heightOptional. Will use existing size otherwise. Height of the render target. Must be greater than 0.

Definition at line 69 of file RenderTexture.cpp.

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

◆ save()

void galaxy::graphics::RenderTexture::save ( std::string_view file)

Saves texture to file on disk.

Parameters
filePath and filename to save texture to. Does not need extension (it will be ignored).

Definition at line 82 of file RenderTexture.cpp.

+ Here is the call graph for this function:

◆ bind()

void galaxy::graphics::RenderTexture::bind ( bool clear = true)

Activate context.

Parameters
clearClear framebuffer after binding.

Definition at line 119 of file RenderTexture.cpp.

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

◆ unbind()

void galaxy::graphics::RenderTexture::unbind ( )

Deactivate context.

Definition at line 124 of file RenderTexture.cpp.

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

◆ clear()

void galaxy::graphics::RenderTexture::clear ( )

Clear framebuffer attachments.

Definition at line 129 of file RenderTexture.cpp.

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

◆ width()

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

Get texture width.

Is cached for performance.

Returns
Width as int.

Definition at line 134 of file RenderTexture.cpp.

+ Here is the caller graph for this function:

◆ height()

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

Get texture height.

Is cached for performance.

Returns
Height as int.

Definition at line 139 of file RenderTexture.cpp.

+ Here is the caller graph for this function:

◆ texture()

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

Gets framebuffer texture.

Returns
Texture ID.

Definition at line 144 of file RenderTexture.cpp.

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

◆ get_proj()

const glm::mat4 & galaxy::graphics::RenderTexture::get_proj ( )
nodiscard

Get render texture projection.

Returns
Const reference to framebuffer viewport projection.

Definition at line 149 of file RenderTexture.cpp.

+ Here is the caller graph for this function:

◆ fbo()

Framebuffer & galaxy::graphics::RenderTexture::fbo ( )
nodiscard

Get framebuffer.

Returns
Reference to framebuffer.

Definition at line 154 of file RenderTexture.cpp.

◆ operator=() [2/2]

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

Copy assignment operator.

Member Data Documentation

◆ m_width

int galaxy::graphics::RenderTexture::m_width
private

Cached width.

Definition at line 148 of file RenderTexture.hpp.

◆ m_height

int galaxy::graphics::RenderTexture::m_height
private

Cached height.

Definition at line 153 of file RenderTexture.hpp.

◆ m_framebuffer

Framebuffer galaxy::graphics::RenderTexture::m_framebuffer
private

OpenGL framebuffer abstraction.

Definition at line 158 of file RenderTexture.hpp.

◆ m_proj

glm::mat4 galaxy::graphics::RenderTexture::m_proj
private

Projection.

Definition at line 163 of file RenderTexture.hpp.


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