esp::gfx::RenderTarget class

Holds a framebuffer and encapsulates the logic of retrieving rendering results of various types (RGB, Depth, ObjectID) from the framebuffer.

Reads the rendering results into either CPU or GPU, if compiled with CUDA, memory

Constructors, destructors, conversion operators

RenderTarget(const Magnum::Vector2i& size, const Magnum::Vector2& depthUnprojection, DepthShader* depthShader)
Constructor.
RenderTarget(const Magnum::Vector2i& size, const Magnum::Vector2& depthUnprojection)
Constructor.
~RenderTarget()
RenderTarget(const RenderTarget&) deleted

Public functions

void renderEnter()
Called before any draw calls that target this RenderTarget Clears the framebuffer and binds it.
void renderExit()
Called after any draw calls that target this RenderTarget.
auto framebufferSize() const -> Magnum::Vector2i
The size of the framebuffer in WxH.
void readFrameRgba(const Magnum::MutableImageView2D& view)
Retrieve the RGBA rendering results.
void readFrameDepth(const Magnum::MutableImageView2D& view)
Retrieve the depth rendering results.
void readFrameObjectId(const Magnum::MutableImageView2D& view)
Reads the ObjectID rendering results into the memory specified by view.
void blitRgbaToDefault()
Blits the rgba buffer from internal FBO to default frame buffer which in case of EmscriptenApplication will be a canvas element.
auto operator=(const RenderTarget&) -> RenderTarget& deleted

Function documentation

esp::gfx::RenderTarget::RenderTarget(const Magnum::Vector2i& size, const Magnum::Vector2& depthUnprojection, DepthShader* depthShader)

Constructor.

Parameters
size The size of the underlying framebuffers in WxH
depthUnprojection Depth unprojection parameters. See calculateDepthUnprojection()
depthShader A DepthShader used to unproject depth on the GPU. Unprojects the depth on the CPU if nullptr. Must be not nullptr to use readFrameDepthGPU()

esp::gfx::RenderTarget::RenderTarget(const Magnum::Vector2i& size, const Magnum::Vector2& depthUnprojection)

Constructor.

Parameters
size The size of the underlying framebuffers in WxH
depthUnprojection Depth unrpojection parameters. See calculateDepthUnprojection()

Equivalent to calling RenderTarget(size, depthUnprojection, nullptr)

void esp::gfx::RenderTarget::readFrameRgba(const Magnum::MutableImageView2D& view)

Retrieve the RGBA rendering results.

Parameters
view in/out Preallocated memory that will be populated with the result. The result will be read as the pixel format of this view.

void esp::gfx::RenderTarget::readFrameDepth(const Magnum::MutableImageView2D& view)

Retrieve the depth rendering results.

Parameters
view in/out Preallocated memory that will be populated with the result. The PixelFormat of the image must only specify the R channel, generally Magnum::PixelFormat::R32F

void esp::gfx::RenderTarget::readFrameObjectId(const Magnum::MutableImageView2D& view)

Reads the ObjectID rendering results into the memory specified by view.

Parameters
view in/out Preallocated memory that will be populated with the result. The PixelFormat of the image must only specify the R channel and be a format which a uint16_t can be interpreted as, generally Magnum::PixelFormat::R32UI, Magnum::PixelFormat::R32I, or Magnum::PixelFormat::R16UI