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

@@ -22,7 +22,7 @@ public:
GLuint VAO;
GLuint VBO;
GLuint EBO;
std::vector<GLuint> UnimLocs;
std::vector<GLint> UnimLocs;
DrawLogicFunc DrawFunc = nullptr;
};
@@ -37,6 +37,8 @@ private:
glm::mat4 _UIOrthoMatrix;
// 渲染的正交投影矩阵
glm::mat4 _OrthoMatrix;
/**视口 */
SDL_Rect _viewport;
// 渲染器上下文
SDL_GLContext _ctx;
@@ -50,40 +52,64 @@ private:
// 当前使用渲染参数
GL_RenderParams _currentRenderParams;
// 渲染透明度
float opacity_ = 1.0f;
// 渲染矩阵
glm::mat4 _currentMatrix;
public:
// 单帧渲染调用次数
int _frameRenderCount = 0;
public:
RenderManager(SDL_Window *window);
~RenderManager();
// 初始化着色器程序
/**初始化着色器程序 */
void InitShaderProgram();
// 初始化绘制2D纹理缓冲程序
/**初始化绘制2D纹理缓冲程序 */
void Init2DTextureProgram();
// 设定当前使用的着色器程序
/**初始化绘制矩形缓冲程序 */
void InitRectProgram();
/**设定当前使用的着色器程序 */
void SetCurrentShaderProgram(std::string name);
// 设定当前使用的缓冲对象
/**设定当前使用的缓冲对象 */
void SetCurrentBufferObject(std::string name);
// 清空屏幕
/**清空屏幕 */
void ClearScreen();
// 交换缓冲区
/**交换缓冲区 */
void SwapBuffer();
// 设置裁切区域
/**设置裁切区域 */
void SetClipRect(const SDL_Rect *rect);
// 关闭裁切区域
/**关闭裁切区域 */
void CloseClipRect();
// 绘制纹理
void DrawTexture(RefPtr<Texture> texture, const SDL_Rect *srcrect, const SDL_FRect *dstrect, const double angle, const SDL_FPoint *center, const SDL_RendererFlip flip, void *userdata = nullptr);
// 设置正交投影矩阵类型
/**设置渲染透明度 */
void SetOpacity(float opacity);
/**获取渲染透明度 */
float GetOpacity();
/**设置渲染矩阵 */
void SetMatrix(glm::mat4 matrix);
/**获取渲染矩阵 */
glm::mat4 GetMatrix();
/**设置混合模式 */
void SetBlendMode(LE_BlEND_MODE blendMode);
/**绘制纹理 */
void DrawTexture(RefPtr<Texture> texture);
/**绘制矩形 */
void DrawRect(const SDL_Rect *rect, glm::vec4 color);
/**设置正交投影矩阵类型 */
void SetOrthoMatrixType(int type);
// 获取渲染的正交投影矩阵
/**获取渲染的正交投影矩阵 */
glm::mat4 GetOrthoMatrix();
// 设置渲染的正交投影矩阵
/**设置渲染的正交投影矩阵 */
void SetOrthoMatrix(glm::mat4 matrix);
/**设置视口 */
void SetViewport(SDL_Rect viewport);
/**获取视口 */
SDL_Rect GetViewport();
private:
// 编译着色器