sculpto
Public Member Functions | List of all members
scl::gl_frame_buffer Class Reference

#include <gl_frame_buffer.h>

Inheritance diagram for scl::gl_frame_buffer:
scl::frame_buffer

Public Member Functions

void SetFrameBufferProps (const frame_buffer_props &Props)
 
const frame_buffer_propsGetFrameBufferProps () const
 
const shared< texture_2d > & GetColorAttachment (int Index) const override
 
const shared< texture_2d > & GetDepthAttachment (int Index) const override
 
render_primitive::handle GetHandle () const override
 
 gl_frame_buffer (const frame_buffer_props &Props)
 
 ~gl_frame_buffer () override
 
void Bind () const override
 
void Unbind () const override
 
void Resize (int Width, int Height) override
 
void Free () override
 
void Clear () override
 
- Public Member Functions inherited from scl::frame_buffer
virtual void SetFrameBufferProps (const frame_buffer_props &Props)=0
 
virtual const frame_buffer_propsGetFrameBufferProps () const =0
 
virtual const shared< texture_2d > & GetColorAttachment (int Index=0) const =0
 
virtual const shared< texture_2d > & GetDepthAttachment (int Index=0) const =0
 
virtual ~frame_buffer ()=default
 
virtual void Bind () const =0
 
virtual void Unbind () const =0
 
virtual void Resize (int Width, int Height)=0
 
virtual void Free ()=0
 
virtual void Clear ()=0
 

Additional Inherited Members

- Static Public Member Functions inherited from scl::frame_buffer
static shared< frame_bufferCreate (const frame_buffer_props &Props)
 

Detailed Description

OpenGL frame buffer class.

Definition at line 18 of file gl_frame_buffer.h.

Constructor & Destructor Documentation

◆ gl_frame_buffer()

scl::gl_frame_buffer::gl_frame_buffer ( const frame_buffer_props Props)
  • OpenGL frame buffer constructor.
Parameters
Props- frame buffer properties.

Definition at line 85 of file gl_frame_buffer.cpp.

85 :
86 Props(Props)
87{
88 this->Invalidate();
89 SCL_CORE_SUCCES("OpenGL Frame Buffer with id {} created.", Id);
90}
#define SCL_CORE_SUCCES(...)
Definition: log.h:42

◆ ~gl_frame_buffer()

scl::gl_frame_buffer::~gl_frame_buffer ( )
override

OpenGL frame buffer default destructor.

Definition at line 92 of file gl_frame_buffer.cpp.

93{
94 this->Free();
95}

Member Function Documentation

◆ Bind()

void scl::gl_frame_buffer::Bind ( ) const
overridevirtual
  • Bind frame buffer to current render stage function.
Parameters
None.
Returns
None.

Implements scl::frame_buffer.

Definition at line 97 of file gl_frame_buffer.cpp.

98{
99 glBindFramebuffer(GL_FRAMEBUFFER, Id);
100 glViewport(0, 0, Props.Width, Props.Height);
101}

◆ Clear()

void scl::gl_frame_buffer::Clear ( )
overridevirtual
  • Clear frame buffer funcrion.
Parameters
None.
Returns
None.

Implements scl::frame_buffer.

Definition at line 128 of file gl_frame_buffer.cpp.

129{
130 this->Bind();
131 glClear(ClearConfig);
132 this->Unbind();
133}
void Bind() const override
void Unbind() const override

◆ Free()

void scl::gl_frame_buffer::Free ( )
overridevirtual
  • Unload frame buffer render target texture from GPU memory function.
Parameters
None.
Returns
None.

Implements scl::frame_buffer.

Definition at line 115 of file gl_frame_buffer.cpp.

116{
117 if (Id != 0) glDeleteFramebuffers(1, &Id);
118
119 for (auto &color_attachment : ColorAttachments) color_attachment.reset();
120 ColorAttachments.clear();
121
122 if (DepthAttachment) DepthAttachment.reset();
123
124 SCL_CORE_INFO("OpenGL Frame Buffer with id {} freed.", Id);
125 Id = 0;
126}
#define SCL_CORE_INFO(...)
Definition: log.h:41

◆ GetColorAttachment()

const scl::shared< scl::texture_2d > & scl::gl_frame_buffer::GetColorAttachment ( int  Index) const
overridevirtual

Frame buffer color attachment getter function.

Implements scl::frame_buffer.

Definition at line 25 of file gl_frame_buffer.cpp.

26{
27 return ColorAttachments[Index];
28}

◆ GetDepthAttachment()

const scl::shared< scl::texture_2d > & scl::gl_frame_buffer::GetDepthAttachment ( int  Index) const
overridevirtual

Frame buffer depth attachment getter function.

Implements scl::frame_buffer.

Definition at line 30 of file gl_frame_buffer.cpp.

31{
32 return DepthAttachment;
33}

◆ GetFrameBufferProps()

const scl::frame_buffer_props & scl::gl_frame_buffer::GetFrameBufferProps ( ) const
virtual

Frame buffer properties getter function.

Implements scl::frame_buffer.

Definition at line 20 of file gl_frame_buffer.cpp.

21{
22 return Props;
23}

◆ GetHandle()

render_primitive::handle scl::gl_frame_buffer::GetHandle ( ) const
inlineoverride

Backend api render primitive hadnle getter function.

Definition at line 48 of file gl_frame_buffer.h.

48{ return Id; }

◆ Resize()

void scl::gl_frame_buffer::Resize ( int  Width,
int  Height 
)
overridevirtual
  • Resize frame buffer (resize also could be called by setting frame buffer props).
Parameters
Width- new frame buffer width.
Height- new frame buffer height.
Returns
None.

Implements scl::frame_buffer.

Definition at line 108 of file gl_frame_buffer.cpp.

109{
110 Props.Width = Width;
111 Props.Height = Height;
112 this->Invalidate();
113}

◆ SetFrameBufferProps()

void scl::gl_frame_buffer::SetFrameBufferProps ( const frame_buffer_props Props)
virtual

Frame buffer getter/setter functions.

Frame buffer properties setter function.

Implements scl::frame_buffer.

Definition at line 13 of file gl_frame_buffer.cpp.

14{
15 this->Props = Props;
16 this->Invalidate();
17 SCL_CORE_INFO("OpenGL Frame Buffer with id {} props changed.", Id);
18}

◆ Unbind()

void scl::gl_frame_buffer::Unbind ( ) const
overridevirtual
  • Unbind frame buffer from current render stage function.
Parameters
None.
Returns
None.

Implements scl::frame_buffer.

Definition at line 103 of file gl_frame_buffer.cpp.

104{
105 glBindFramebuffer(GL_FRAMEBUFFER, 0);
106}

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