![]() |
ImFusion SDK 4.3
|
#include <ImFusion/Core/GL/OffscreenRenderHelper.h>
Helper class to perform deferred off-screen rendering. More...
Inheritance diagram for OffscreenRenderHelper:Helper class to perform deferred off-screen rendering.
This class helps you to accumulate your rendering calls into a temporary texture before eventually copying/blending the accumulated pixels back to the original/parent framebuffer. Internally, the temporary textures and framebuffer objects are cached and reused if compatible to avoid performance issues due to constant reallocation.
A typical usage scenario looks like this:
Classes | |
| struct | RenderBuffer |
| Helper structure to encapsulate OpenGL objects representing the temporary rendering buffer. More... | |
Public Types | |
| enum class | ColorPostProcessing { None = 0 , DivideByAlpha = 1 , DivideBySqrtAlpha = 2 } |
| Enumeration of optional additional color processing steps to perform in the copy shader. More... | |
Public Member Functions | |
| RenderBuffer | create (const vec2i &viewportSize, GL::InternalFormat colorFormat=GL::InternalFormat::RGBA8, GL::InternalFormat depthFormat=GL::InternalFormat::DepthComponent24) |
| Creates a new temporary render buffer of the given configuration for off-screen rendering. | |
| int | cacheSize () const |
| Returns the maximum number of RenderBuffer instances that are cached by OffscreenRenderHelper. | |
| void | setCacheSize (int numElements) |
| Sets the maximum number of RenderBuffer instances that are cached by OffscreenRenderHelper; must not be negative. | |
Additional Inherited Members | |
Static Public Member Functions inherited from InstanceManager< OffscreenRenderHelper > | |
| static OffscreenRenderHelper & | cachedInstance () |
| Returns the cached instance of type T for the currently active OpenGL context. | |
|
strong |
Enumeration of optional additional color processing steps to perform in the copy shader.
| Enumerator | |
|---|---|
| None | Write the original RGBA value of the color texture to the fragment shader output. |
| DivideByAlpha | Divide the RGB value by the alpha component. This is useful if you are using pre-multiplied alpha blending and want to reverse the pre-multiplication process in a single pass. |
| DivideBySqrtAlpha | Divide the RGBA value by If your blending setup is |
|
nodiscard |
Creates a new temporary render buffer of the given configuration for off-screen rendering.
After calling this function and capturing the returned RenderBuffer the current OpenGL context will have bound a dedicated FBO with one color and one depth texture of the given formats attached. The textures will be cleared with color vec4(0, 0, 0, 0) and depth 1 and the OpenGL viewport will be set to size viewportSize with offset (0, 0).
The original FBO and viewport state will be restored when the RenderBuffer is destroyed or you call RenderBuffer::blendToParent().
| viewportSize | Size in pixels of the temporary render buffer |
| colorFormat | Internal texture format to use for the color attachment. |
| depthFormat | Internal texture format to use for the depth attachment. |