12 linear_filter_ = linearFilter;
22 if (!framebuffer_ && floatColor) {
43 framebuffer_->unbind();
48 if (width == width_ && height == height_)
return;
54 framebuffer_->resize(width, height);
73 if (!free_list_.empty()) {
74 handle = free_list_.back();
75 free_list_.pop_back();
77 handle = next_handle_++;
78 targets_.resize(handle);
82 target->init(*device_, width, height, depth, linearFilter, floatColor);
84 usize index = handle - 1;
85 if (index < targets_.size()) {
86 targets_[index] = std::move(target);
96 return targets_[handle - 1].get();
104 auto& target = targets_[handle - 1];
108 free_list_.push_back(handle);
116 return targets_[handle - 1] !=
nullptr;
Abstract graphics device interface.
static Unique< Framebuffer > create(GfxDevice &device, const FramebufferSpec &spec)
Creates a framebuffer from specification.
Abstract graphics device interface.
virtual bool supportsFloatTargets()=0
Whether RGBA16F color attachments are renderable.
Handle create(u32 width, u32 height, bool depth=true, bool linearFilter=false, bool floatColor=false)
static constexpr Handle INVALID_HANDLE
void release(Handle handle)
RenderTarget * get(Handle handle)
bool isValid(Handle handle) const
TextureHandle getDepthTexture() const
TextureHandle getColorTexture() const
void init(GfxDevice &device, u32 width, u32 height, bool depth=true, bool linearFilter=false, bool floatColor=false)
void resize(u32 width, u32 height)
FramebufferHandle getFramebuffer() const
FramebufferHandle
Handle 0 is the default framebuffer (backbuffer); it cannot be created or deleted.
constexpr Unique< T > makeUnique(Args &&... args)
Creates a Unique pointer with the given arguments.
std::size_t usize
Size type for indexing and sizes.
std::uint32_t u32
Unsigned 32-bit integer.
Framebuffer creation parameters.
GfxPixelFormat colorFormat
Color attachment format. RGBA16F needs GfxDevice::supportsFloatTargets.
bool depthStencil
Whether to create depth/stencil attachment.
bool linearFilter
Texture filter mode: false=GL_NEAREST, true=GL_LINEAR.
u32 height
Framebuffer height in pixels.
u32 width
Framebuffer width in pixels.