Extra2D/include/renderer/rhi/opengl/gl_pipeline.h

46 lines
1.0 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#pragma once
#include <renderer/rhi/rhi.h>
#include <glad/glad.h>
namespace extra2d {
// 前向声明
class GLShader;
/**
* @brief OpenGL 管线实现
*/
class GLPipeline : public RHIPipeline {
public:
explicit GLPipeline(const PipelineDesc& desc);
~GLPipeline() override;
bool create();
void destroy();
void bind() override;
void unbind() override;
ShaderHandle getVertexShader() const override;
ShaderHandle getFragmentShader() const override;
const VertexLayout& getVertexLayout() const override;
bool isValid() const override;
const PipelineDesc& getDesc() const { return desc_; }
GLuint getGLVAO() const { return vao_; }
// 获取 shader program ID用于设置 uniform
GLuint getGLProgram() const { return shaderProgram_; }
// 设置 shader program ID在创建时调用
void setGLProgram(GLuint program) { shaderProgram_ = program; }
private:
PipelineDesc desc_;
GLuint vao_;
GLuint shaderProgram_ = 0;
};
} // namespace extra2d