feat(动画): 添加角色动作合成纹理功能

实现角色动作的离屏渲染合成功能,支持获取合成纹理及其相关信息:
1. 新增CanvasActor用于离屏渲染
2. 新增RenderTexture封装FBO和纹理
3. 扩展Renderer支持离屏渲染到纹理
4. 为CharacterAnimation添加合成纹理生成逻辑
5. 在调试界面添加合成纹理预览功能
This commit is contained in:
2026-04-07 06:17:49 +08:00
parent 6684abd131
commit 808431f92c
14 changed files with 1207 additions and 22 deletions

View File

@@ -9,9 +9,12 @@
#include <frostbite2D/graphics/texture.h>
#include <frostbite2D/graphics/types.h>
#include <string>
#include <vector>
namespace frostbite2D {
class RenderTexture;
class Renderer {
public:
static Renderer& get();
@@ -22,6 +25,10 @@ public:
void beginFrame();
void endFrame();
void flush();
bool beginRenderToTexture(RenderTexture& target, Camera* camera,
const Color& clearColor = Color(0.0f, 0.0f, 0.0f, 0.0f),
bool clear = true);
bool endRenderToTexture();
void setViewport(int x, int y, int width, int height);
void setWindowSize(int width, int height, float contentScaleX = 1.0f,
@@ -61,6 +68,9 @@ public:
const RenderResolutionState& getResolutionState() const {
return resolutionState_;
}
bool isInitialized() const { return initialized_; }
bool isFrameActive() const { return frameActive_; }
bool isRenderingToTexture() const { return !renderTargetStack_.empty(); }
Vec2 screenToVirtual(const Vec2& screenPos) const;
Vec2 virtualToScreen(const Vec2& virtualPos) const;
@@ -107,6 +117,17 @@ private:
void recalculateResolutionState();
void syncCameraViewport();
struct RenderTargetState {
uint32 framebuffer = 0;
int viewportX = 0;
int viewportY = 0;
int viewportWidth = 1;
int viewportHeight = 1;
float clearColor[4] = {0.0f, 0.0f, 0.0f, 0.0f};
Camera* camera = nullptr;
bool startedStandaloneBatch = false;
};
ShaderManager shaderManager_;
Batch batch_;
Camera* camera_ = nullptr;
@@ -123,6 +144,8 @@ private:
RenderResolutionState resolutionState_;
bool initialized_ = false;
bool frameActive_ = false;
std::vector<RenderTargetState> renderTargetStack_;
Renderer(const Renderer&) = delete;
Renderer& operator=(const Renderer&) = delete;