summaryrefslogtreecommitdiff
path: root/Client/Source/Graphics/Shader.h
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Source/Graphics/Shader.h')
-rw-r--r--Client/Source/Graphics/Shader.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/Client/Source/Graphics/Shader.h b/Client/Source/Graphics/Shader.h
new file mode 100644
index 0000000..8d5fc0e
--- /dev/null
+++ b/Client/Source/Graphics/Shader.h
@@ -0,0 +1,47 @@
+#pragma once
+#include <string>
+#include <exception>
+#include "OpenGL.h"
+#include "../Utilities/UtilMacros.h"
+#include "../Utilities/Assert.h"
+#include "../Debug/Log.h"
+#include "RenderCommands.h"
+
+// 着色器程序
+class Shader
+{
+public:
+ Shader()/*throw(ShaderCompileExecption)*/;
+ Shader(std::string& glsllShader)/*throw(ShaderCompileExecption)*/;
+ Shader(const char* vert, const char* frag)/*throw(ShaderCompileExecption)*/;
+ ~Shader();
+
+ void ReCompile(std::string& vert, std::string frag)/*throw(ShaderCompileExecption)*/;
+ void ReCompileVert(std::string& vert)/*throw(ShaderCompileExecption)*/;
+ void ReCompileFrag(std::string frag)/*throw(ShaderCompileExecption)*/;
+
+ bool IsValid();
+
+ void ExecuteCommand();
+
+ GET(GLint, ID, m_ProgramID);
+
+private:
+ void CompileProgram(const char* vert, const char* frag, bool keepSrc = false);
+
+ RenderCommandGroup m_Commands; // 渲染前的状态设置
+
+ GLint m_ProgramID;
+ GLint m_FragID;
+ GLint m_VertID;
+
+};
+
+class ShaderCompileExecption : public std::exception
+{
+public:
+ ShaderCompileExecption(const char* what)
+ : std::exception(what)
+ {
+ }
+};