This commit is contained in:
2026-02-08 16:20:50 +08:00
parent 0ae47e5d6a
commit 8b88904ef7
72 changed files with 5963 additions and 2038 deletions

View File

@@ -18,37 +18,37 @@ class Canvas : public Actor
return index < other.index; // 字符串相同则比较index
}
};
struct DrawInfo
{
ImgKey texture;
SDL_FRect rect = {0, 0, 0, 0};
};
private:
/**纹理 */
RefPtr<Texture> m_texture = nullptr;
/**大小 */
VecSize m_size;
/**渲染大小 */
SDL_Rect m_renderRect;
SDL_FRect m_rect;
/**脏标记 */
bool m_dirty = true;
/**FBO */
GLuint m_fbo = 0;
/**绘制纹理集 */
std::map<ImgKey, RefPtr<Texture>> m_imgMap;
/**绘制队列 */
std::vector<DrawInfo> m_drawQueue;
/**原始的正交矩阵 */
glm::mat4 Oom;
/**原始的视口 */
SDL_Rect Oviewport;
public:
Canvas();
Canvas(VecSize size);
Canvas(int width, int height);
void PreRender() override;
void Render() override;
void Blend();
/**初始化 */
void Init(VecSize size);
void DrawImg(std::string img, int index, Vec2 pos);
void DrawImg(std::string img, int index, SDL_FRect rect);
/**开始绘制 */
void BeginDraw();
/**结束绘制 */
void EndDraw();
/**绘制角色 */
void DrawActor(RefPtr<Actor> actor);
/**清空画布 */
void Clear();
/**重载OnRender函数 */
void OnRender() override;
};