summaryrefslogtreecommitdiff
path: root/Runtime/Graphics/Shader.h
diff options
context:
space:
mode:
Diffstat (limited to 'Runtime/Graphics/Shader.h')
-rw-r--r--Runtime/Graphics/Shader.h56
1 files changed, 55 insertions, 1 deletions
diff --git a/Runtime/Graphics/Shader.h b/Runtime/Graphics/Shader.h
index b22a05f..7cca768 100644
--- a/Runtime/Graphics/Shader.h
+++ b/Runtime/Graphics/Shader.h
@@ -1,6 +1,60 @@
#pragma once
+#include <string>
+#include <exception>
+#include "Runtime/Graphics/OpenGL.h"
+#include "Runtime/Lua/LuaHelper.h"
+#include "Runtime/Utilities/UtilMacros.h"
+#include "runtime/Debug/Log.h"
-class Shader
+// ×ÅÉ«Æ÷³ÌÐò
+class Shader : public LuaBind::NativeClass<Shader>
{
+public:
+ Shader(LuaBind::VM*vm, bool keepSrc = false);
+ Shader(LuaBind::VM*vm, std::string& vert, std::string& frag, bool keepSrc = false)/*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();
+
+ GET(GLint, ID, m_ProgramID);
+
+private:
+ bool m_KeepSrc;
+
+ std::string m_VertSrc;
+ std::string m_FragSrc;
+
+ GLint m_ProgramID;
+ GLint m_FragID;
+ GLint m_VertID;
+
+ LUA_BIND_DECL_CLASS(Shader);
+
+ LUA_BIND_DECL_METHOD(_New);
+ LUA_BIND_DECL_METHOD(_ReCompile);
+ LUA_BIND_DECL_METHOD(_ReCompileVert);
+ LUA_BIND_DECL_METHOD(_ReCompileFrag);
+ LUA_BIND_DECL_METHOD(_IsValid);
+ LUA_BIND_DECL_METHOD(_GetVertCode);
+ LUA_BIND_DECL_METHOD(_GetFragCode);
};
+
+class ShaderCompileExecption : public std::exception
+{
+public:
+ ShaderCompileExecption(std::string& err)
+ {
+ m_Err = err;
+ }
+ char const* what() const override
+ {
+ return m_Err.c_str();
+ }
+private:
+ std::string m_Err;
+}; \ No newline at end of file