Framebuffers¶
/* Declarations */
GPUFramebuffer m_framebuffer;
GPUTexture m_texture;
/* Texture Creation */
TextureDesc desc = {};
desc.width = 256u;
desc.height = 256u;
desc.pixeltype = GL_UNSIGNED_BYTE;
desc.internal = GL_RGBA8;
desc.format = GL_RGBA;
Texture::CreateEmpty2D(&m_texture, desc);
Texture::SetParameters(&m_texture, SamplerDesc::Default2D() );
/* Framebuffer Creation */
Framebuffer::CreateFromTexture(&m_framebuffer,m_texture, true);
/* Framebuffer Usage */
Framebuffer::Bind(m_framebuffer);
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glViewport(0,0,256,256);
/* Pipelines, Drawcalls, etc... */
}
Framebuffer::BindDefault();
/* Display */
Texture::GenerateMipmap(&m_texture);
DebugUI::ShowTexture("Frame",m_texture.id,IO::FrameWidth()/2.f,IO::FrameHeight()/2.f);
Framebuffer API Description¶
-
struct GPUFramebuffer¶
OpenGL framebuffer object data structure.
-
namespace Framebuffer¶
Functions
-
void CreateFromTexture(GPUFramebuffer *fbo, const GPUTexture &texture, bool renderbuffer = false, bool multisampled = false)¶
Create a GPUFramebuffer from a GPUTexture.
-
void CreateFromTexture(GPUFramebuffer *fbo, const GPUTexture &texture, const GPUTexture &depth)¶
Create a GPUFramebuffer from a GPUTexture and a depth texture.
-
void CreateFromArray(GPUFramebuffer *fbo, const GPUTexture &texture2darray, bool renderbuffer = false, bool multisampled = false)¶
Create a GPUFramebuffer from a GPUTexture 2D array.
-
void CreateFromArray(GPUFramebuffer *fbo, const GPUTexture &texture2darray, const GPUTexture &depth)¶
Create a GPUFramebuffer from a GPUTexture 2D array and a depth texture.
-
void CreateFromArray(GPUFramebuffer *fbo, GPUTexture *textures, uint32_t size, bool renderbuffer = false, bool multisampled = false)¶
Create a GPUFramebuffer from an array of GPUTexture (must have same resolution)
-
void CreateFromArray(GPUFramebuffer *fbo, GPUTexture *textures, uint32_t size, const GPUTexture &depth)¶
Create a GPUFramebuffer from an array of GPUTexture (must have same resolution) and a depth texture.
-
void CreateFromDepthOnly(GPUFramebuffer *fbo, const GPUTexture &depth)¶
Create a GPUFramebuffer only from an existing depth texture.
-
void Destroy(GPUFramebuffer *fbo)¶
Destroys a GPUFramebuffer
-
void Bind(const GPUFramebuffer &fbo)¶
Enables a GPUFramebuffer
-
void BindDefault()¶
Enables the default framebuffer
-
void Blit(const GPUFramebuffer &fbo_to_read, const GPUFramebuffer &fbo_to_write, uint32_t width, uint32_t height, uint32_t attachment)¶
Blits two framebuffers
-
void CreateFromTexture(GPUFramebuffer *fbo, const GPUTexture &texture, bool renderbuffer = false, bool multisampled = false)¶