|
Axmol 3.0.0-89d6d9a
|
Manages an offscreen render pass into a RenderTexture. More...
#include <RenderTexturePass.h>
Inherits Object.
Public Member Functions | |
| void | setCameraOverrideEnabled (bool enabled) |
| Enables or disables automatic camera adjustment for this pass. | |
| bool | isCameraOverrideEnabled () const |
| Returns whether this pass automatically overrides the visiting camera. | |
Target | |
| void | setTarget (RenderTexture *rt) |
Viewport | |
| void | setViewport (std::optional< Viewport > vp) |
| Viewport | makeVirtualViewport (const Vec2 &rtBegin, const Rect &fullRect, const Rect &fullViewport) const |
| Computes a virtual viewport rectangle for rendering into a RenderTexture. | |
Lifecycle | |
| void | begin (const Camera *camera=nullptr) |
| Begin offscreen rendering. | |
| void | end () |
| End offscreen rendering. | |
Clear (must be called between begin() / end()) | |
| void | clear (ClearFlag flags, const ClearValue &value=ClearValue{}) |
| Clear the active render target. | |
| void | clearColor (const Color &color) |
| Clear color buffer only. | |
| void | clearDepth (float depth) |
| Clear depth buffer only. | |
| void | clearStencil (unsigned int stencil) |
| Clear stencil buffer only. | |
| void | clearAll (const ClearValue &value=ClearValue{}) |
| Clear all buffers (color|depth|stencil). | |
| Public Member Functions inherited from Object | |
| void | retain () |
| Retains the ownership. | |
| void | release () |
| Releases the ownership immediately. | |
| Object * | autorelease () |
| Releases the ownership sometime soon automatically. | |
| unsigned int | getReferenceCount () const |
| Returns the Object's current reference count. | |
| uint64_t | getObjectID () const noexcept |
| Returns the process-local diagnostic identifier assigned at construction. | |
| virtual | ~Object () |
| Destructor. | |
Static Public Member Functions | |
| static RenderTexturePass * | obtain (RenderTexture *rt=nullptr) |
| Obtain a new render texture pass instance (ref count 1, does not enter autorelease pool). | |
Manages an offscreen render pass into a RenderTexture.
RenderTexturePass is a lightweight helper that brackets a group of renderer commands between begin() and end(). Commands submitted while the pass is active are recorded into a dedicated renderer group. When that group is executed, the pass saves the current render target and viewport, binds the RenderTexture's render target, optionally applies a custom viewport, and restores the previous state at the end of the group.
This class is intentionally not a render target resource. It does not own the RenderTexture, does not traverse a scene by itself, and does not flush the renderer automatically. Callers are responsible for submitting draw commands between begin() and end(), then flushing the renderer at an appropriate time.
Axmol's renderer does not execute commands strictly in submission order. Render queues are sorted by type and global order; in particular, 3D commands may be processed before regular GLOBALZ_ZERO commands. For this reason, the internal begin callback must be scheduled with an early global order, and the internal end callback must be scheduled with a late global order. This guarantees that all commands submitted between begin() and end(), including 3D, 2D, debug draw, and custom commands, are executed while the RenderTexture is bound.
The clear() helpers are also scheduled after the render target has been bound and before normal draw commands, so they clear the intended RenderTexture rather than the previously active render target.
On OpenGL, offscreen FBO textures have a bottom-left origin, while D3D, Metal, and Vulkan use a top-left origin. When automatic Y flipping is enabled, this pass can flip the selected camera's projection matrix on OpenGL so that the rendered texture has a consistent orientation across backends.
Use a separate RenderTexturePass object for nested render target passes.
|
static |
Obtain a new render texture pass instance (ref count 1, does not enter autorelease pool).
| rt | Optional render texture to assign. If null, call setTarget() before begin(). |
| void setTarget | ( | RenderTexture * | rt | ) |
Set render target. Must be called before begin(), not while active.
| void setViewport | ( | std::optional< Viewport > | vp | ) |
Set custom viewport. Must be called before begin().
| Viewport makeVirtualViewport | ( | const Vec2 & | rtBegin, |
| const Rect & | fullRect, | ||
| const Rect & | fullViewport ) const |
Computes a virtual viewport rectangle for rendering into a RenderTexture.
This function maps a sub-rectangle of the full render target (fullRect) into the coordinate space of the specified full viewport (fullViewport), relative to the RenderTexture begin offset (rtBegin). It produces a Viewport object that can be used for scissor or rendering operations inside the RenderTexture.
| rtBegin | The origin offset (x, y) of the RenderTexture region where rendering begins. |
| fullRect | The full rectangle of the RenderTexture in local coordinates. |
| fullViewport | The full viewport rectangle in local coordinates. |
| void begin | ( | const Camera * | camera = nullptr | ) |
Begin offscreen rendering.
| camera | Optional camera used for backend-specific projection adjustment. Saves current render target/viewport, pushes render group. |
| void end | ( | ) |
End offscreen rendering.
Restores previous render target/viewport and camera projection.
| void clear | ( | ClearFlag | flags, |
| const ClearValue & | value = ClearValue{} ) |
|
inline |
|
inline |
|
inline |
Enables or disables automatic camera adjustment for this pass.
When enabled, begin() applies backend-specific projection adjustments to the selected camera when needed. end() restores the projection state.
Advanced renderers that manage their own camera loop, such as VR or custom multi-view renderers, can disable this behavior and handle camera state explicitly.
| enabled | True to let RenderTexturePass adjust the selected camera; false to leave camera projection untouched. |