Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
esengine::Framebuffer Class Reference

Off-screen rendering target. More...

#include <Framebuffer.hpp>

Public Member Functions

 Framebuffer ()=default
 ~Framebuffer ()
 Framebuffer (const Framebuffer &)=delete
Framebuffer & operator= (const Framebuffer &)=delete
 Framebuffer (Framebuffer &&other) noexcept
Framebuffer & operator= (Framebuffer &&other) noexcept
void bind () const
 Binds the framebuffer for rendering.
void unbind () const
 Unbinds the framebuffer.
void resize (u32 width, u32 height)
 Resizes the framebuffer.
TextureHandle getColorAttachment () const
 Gets the color attachment texture.
TextureHandle getGBufferAttachment () const
 The second colour attachment, resolved like the first (Invalid when the target has none).
TextureHandle getAlbedoAttachment () const
 The third colour attachment, the surface's diffuse colour (RGBA8, alpha 1 where a surface wrote it).
TextureHandle getDepthAttachment () const
 Gets the depth attachment texture (Invalid if none).
u32 getWidth () const
 Gets the framebuffer width in pixels.
u32 getHeight () const
 Gets the framebuffer height in pixels.
const FramebufferSpec & getSpecification () const
 Gets the framebuffer specification.
FramebufferHandle handle () const
 Gets the device framebuffer handle.

Static Public Member Functions

static Unique< Framebuffer > create (GfxDevice &device, const FramebufferSpec &spec)
 Creates a framebuffer from specification.

Detailed Description

Off-screen rendering target.

Encapsulates an OpenGL/WebGL framebuffer object with color and optional depth attachments. Supports render-to-texture for scene views, post-processing, and shadow maps.

// Create framebuffer
spec.width = 800;
spec.height = 600;
auto fbo = Framebuffer::create(spec);
// Render to texture
fbo->bind();
device.clear(true, true, false);
// ... render scene ...
fbo->unbind();
// Use color texture
TextureHandle texture = fbo->getColorAttachment();
static Unique< Framebuffer > create(GfxDevice &device, const FramebufferSpec &spec)
Creates a framebuffer from specification.
Framebuffer creation parameters.
u32 height
Framebuffer height in pixels.
u32 width
Framebuffer width in pixels.

Definition at line 94 of file Framebuffer.hpp.

Constructor & Destructor Documentation

◆ Framebuffer() [1/3]

esengine::Framebuffer::Framebuffer ( )
default

◆ ~Framebuffer()

esengine::Framebuffer::~Framebuffer ( )

Definition at line 28 of file Framebuffer.cpp.

◆ Framebuffer() [2/3]

esengine::Framebuffer::Framebuffer ( const Framebuffer & )
delete

References Framebuffer().

◆ Framebuffer() [3/3]

esengine::Framebuffer::Framebuffer ( Framebuffer && other)
noexcept

Definition at line 32 of file Framebuffer.cpp.

References Framebuffer(), esengine::Default, and esengine::Invalid.

Member Function Documentation

◆ bind()

void esengine::Framebuffer::bind ( ) const

Binds the framebuffer for rendering.

All subsequent draw calls will render to this framebuffer until unbind() is called.

Definition at line 103 of file Framebuffer.cpp.

◆ create()

Unique< Framebuffer > esengine::Framebuffer::create ( GfxDevice & device,
const FramebufferSpec & spec )
static

Creates a framebuffer from specification.

Parameters
specFramebuffer parameters
Returns
Unique pointer to the framebuffer

Creates framebuffer with color attachment and optional depth/stencil attachment based on spec.

Definition at line 86 of file Framebuffer.cpp.

References ES_LOG_ERROR, and esengine::makeUnique().

Referenced by esengine::rg::TargetPool::acquire(), esengine::PostProcessPipeline::declareCover(), esengine::PostProcessPipeline::declareVelocity(), and esengine::RenderTarget::init().

◆ getAlbedoAttachment()

TextureHandle esengine::Framebuffer::getAlbedoAttachment ( ) const
inline

The third colour attachment, the surface's diffuse colour (RGBA8, alpha 1 where a surface wrote it).

Definition at line 164 of file Framebuffer.hpp.

References esengine::Invalid.

◆ getColorAttachment()

TextureHandle esengine::Framebuffer::getColorAttachment ( ) const
inline

Gets the color attachment texture.

What a shader samples. On a multisampled target this is the RESOLVED attachment, not the one drawn into — the caller never handles the multisampled side, which cannot be sampled at all.

Definition at line 154 of file Framebuffer.hpp.

References esengine::Invalid.

◆ getDepthAttachment()

TextureHandle esengine::Framebuffer::getDepthAttachment ( ) const
inline

Gets the depth attachment texture (Invalid if none).

Definition at line 169 of file Framebuffer.hpp.

References esengine::Invalid.

◆ getGBufferAttachment()

TextureHandle esengine::Framebuffer::getGBufferAttachment ( ) const
inline

The second colour attachment, resolved like the first (Invalid when the target has none).

Definition at line 159 of file Framebuffer.hpp.

References esengine::Invalid.

◆ getHeight()

u32 esengine::Framebuffer::getHeight ( ) const
inline

Gets the framebuffer height in pixels.

Definition at line 177 of file Framebuffer.hpp.

◆ getSpecification()

const FramebufferSpec & esengine::Framebuffer::getSpecification ( ) const
inline

Gets the framebuffer specification.

Definition at line 180 of file Framebuffer.hpp.

◆ getWidth()

u32 esengine::Framebuffer::getWidth ( ) const
inline

Gets the framebuffer width in pixels.

Definition at line 174 of file Framebuffer.hpp.

◆ handle()

FramebufferHandle esengine::Framebuffer::handle ( ) const
inline

Gets the device framebuffer handle.

Definition at line 183 of file Framebuffer.hpp.

◆ operator=() [1/2]

Framebuffer & esengine::Framebuffer::operator= ( const Framebuffer & )
delete

References Framebuffer().

◆ operator=() [2/2]

Framebuffer & esengine::Framebuffer::operator= ( Framebuffer && other)
noexcept

Definition at line 55 of file Framebuffer.cpp.

References Framebuffer(), esengine::Default, and esengine::Invalid.

◆ resize()

void esengine::Framebuffer::resize ( u32 width,
u32 height )

Resizes the framebuffer.

Parameters
widthNew width in pixels
heightNew height in pixels

Recreates all attachments with new dimensions. Existing content is lost.

Definition at line 111 of file Framebuffer.cpp.

References ES_LOG_ERROR, ES_LOG_WARN, and esengine::FramebufferSpec::width.

◆ unbind()

void esengine::Framebuffer::unbind ( ) const

Unbinds the framebuffer.

Restores rendering to the default framebuffer (screen).

Definition at line 107 of file Framebuffer.cpp.


The documentation for this class was generated from the following files:
  • /home/runner/work/estella/estella/src/esengine/renderer/rhi/Framebuffer.hpp
  • /home/runner/work/estella/estella/src/esengine/renderer/rhi/Framebuffer.cpp