From 3239ba18797b1aa098056aa0c2a70e250a27a06c Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 24 Oct 2021 13:24:13 +0800 Subject: * port shader --- Runtime/Graphics/Shader.h | 56 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) (limited to 'Runtime/Graphics/Shader.h') 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 +#include +#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 { +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 -- cgit v1.1-26-g67d0