Files
2026-02-08 16:20:50 +08:00

55 lines
1.1 KiB
C++

#pragma once
#include "EngineFrame/Base/Actor.h"
#include "EngineFrame/Render/Texture.h"
#include "EngineFrame/Component/Sprite.h"
class Canvas : public Actor
{
struct ImgKey
{
std::string img;
int index;
bool operator<(const ImgKey &other) const
{
if (img != other.img)
{
return img < other.img; // 字符串按字典序比较
}
return index < other.index; // 字符串相同则比较index
}
};
private:
/**纹理 */
RefPtr<Texture> m_texture = nullptr;
/**大小 */
VecSize m_size;
/**FBO */
GLuint m_fbo = 0;
/**原始的正交矩阵 */
glm::mat4 Oom;
/**原始的视口 */
SDL_Rect Oviewport;
public:
Canvas();
Canvas(VecSize size);
Canvas(int width, int height);
/**初始化 */
void Init(VecSize size);
/**开始绘制 */
void BeginDraw();
/**结束绘制 */
void EndDraw();
/**绘制角色 */
void DrawActor(RefPtr<Actor> actor);
/**清空画布 */
void Clear();
/**重载OnRender函数 */
void OnRender() override;
};