Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
FrameCapture.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
7#pragma once
8
11#include "./RenderStage.hpp"
12#include "../draw/BlendMode.hpp"
14
15#include <cstddef>
16#include <span>
17#include <vector>
18
19namespace esengine {
20
22enum class CapturePass : u8 {
23 Scene = 0,
25};
26
54
55// The TS decoder (sdk/src/render/frameCapture.ts) reads these offsets.
56static_assert(sizeof(DrawCallRecord) == 84, "DrawCallRecord size must match TS decoder");
57static_assert(offsetof(DrawCallRecord, pass_kind) == 11, "DrawCallRecord layout must match TS decoder");
58static_assert(offsetof(DrawCallRecord, instance_count) == 76, "DrawCallRecord layout must match TS decoder");
59static_assert(offsetof(DrawCallRecord, texture_offset) == 80, "DrawCallRecord layout must match TS decoder");
60
67public:
70 capture_next_ = true;
71 has_data_ = false;
72 }
73
74 void beginFrame();
75 void endFrame();
76 void beginPass(CapturePass kind);
77 i32 currentPass() const { return pass_; }
78
79 bool isCapturing() const { return capturing_; }
80 bool hasCapturedData() const { return has_data_; }
81
83 void record(const DrawCommand& cmd, std::span<const Entity> entities);
84
85 u32 getRecordCount() const { return static_cast<u32>(records_.size()); }
86 const DrawCallRecord* getRecords() const { return records_.data(); }
87 const Entity* getEntities() const { return entities_.data(); }
88 u32 getEntityCount() const { return static_cast<u32>(entities_.size()); }
89 const u32* getTextures() const { return textures_.data(); }
90 u32 getTextureCount() const { return static_cast<u32>(textures_.size()); }
91 u32 getPassCount() const { return pass_count_; }
93 u32 recordsInPass(i32 pass) const;
94
95 void setReplayMode(i32 limit);
96 void clearReplayMode();
97 bool isReplaying() const { return replay_mode_; }
99 bool stepReplay() { return ++replay_counter_ >= replay_limit_; }
100
101private:
102 std::vector<DrawCallRecord> records_;
103 std::vector<Entity> entities_;
104 std::vector<u32> textures_;
105 i32 pass_ = -1;
106 CapturePass pass_kind_ = CapturePass::Scene;
107 u32 pass_count_ = 0;
108 bool capturing_ = false;
109 bool capture_next_ = false;
110 bool has_data_ = false;
111
112 bool replay_mode_ = false;
113 i32 replay_counter_ = 0;
114 i32 replay_limit_ = -1;
115};
116
117} // namespace esengine
Blend mode enumeration for custom rendering.
Core type definitions and utilities for ESEngine.
const u32 * getTextures() const
void record(const DrawCommand &cmd, std::span< const Entity > entities)
const Entity * getEntities() const
void beginPass(CapturePass kind)
const DrawCallRecord * getRecords() const
u32 recordsInPass(i32 pass) const
void setReplayMode(i32 limit)
bool hasCapturedData() const
std::int32_t i32
Signed 32-bit integer.
Definition Types.hpp:54
std::uint32_t u32
Unsigned 32-bit integer.
Definition Types.hpp:45
BlendMode
Predefined blend modes for rendering.
Definition BlendMode.hpp:22
std::uint8_t u8
Unsigned 8-bit integer.
Definition Types.hpp:41
Entity identifier with packed index + generation.
Definition Types.hpp:135