-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRenderPass.h
More file actions
85 lines (76 loc) · 2.66 KB
/
Copy pathRenderPass.h
File metadata and controls
85 lines (76 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#pragma once
#include <cstdint>
// Forward declarations
class DekiObject;
struct RenderContext;
/**
* @brief Base class for custom render passes
*
* Register a RenderPass on Standard2DRenderer to add custom
* per-object behavior without modifying the renderer itself.
*
* Execute() is called per-object before children are rendered.
* PostExecute() is called per-object after children are rendered (reverse order).
*
* Usage:
* @code
* class MyEffectPass : public RenderPass {
* void Execute(DekiObject* obj, RenderContext& ctx) override {
* auto* effect = obj->GetComponent<MyEffectComponent>();
* if (!effect) return;
* // Apply effect...
* }
* };
*
* standard2DRenderer.AddPass(&myEffectPass);
* @endcode
*/
class RenderPass
{
public:
virtual ~RenderPass() = default;
/**
* @brief Called once per frame, before any object renders.
*
* Pass may mutate ctx (e.g. swap ctx.buffer to a scratch buffer) to
* install a default render target for the whole frame. The mutated
* ctx is then propagated to every subsequent per-object hook and to
* the built-in render via Standard2DRenderer's frame-scoped context.
*/
virtual void BeginFrame(RenderContext& ctx) {}
/**
* @brief Called per-object BEFORE built-in render (sprite blit, clip push)
*
* Use this to redirect a single object's blit by mutating ctx.buffer
* (and width/height/format if needed). Restore in PostExecute.
*/
virtual void PreExecute(DekiObject* obj, RenderContext& ctx) {}
/**
* @brief Called per-object before children are rendered (after built-in render)
* @param obj The current object being rendered
* @param ctx Render context with camera, buffer, and format info
*/
virtual void Execute(DekiObject* obj, RenderContext& ctx) {}
/**
* @brief Called per-object after children are rendered
* @param obj The current object being rendered
* @param ctx Render context with camera, buffer, and format info
*/
virtual void PostExecute(DekiObject* obj, RenderContext& ctx) {}
/**
* @brief Called once per frame, after all objects have rendered.
*
* Pass may run a screen-space composite by reading from scratch
* buffers it filled during the frame and writing into the original
* framebuffer (saved in BeginFrame).
*/
virtual void EndFrame(RenderContext& ctx) {}
};
/**
* @brief Callback for custom sorting
*
* Returns true if the object is a sortable render item, setting outOrder.
* Register on Standard2DRenderer via AddSortingCallback().
*/
using SortingCallback = bool(*)(DekiObject* obj, int32_t& outOrder);
//