blob: 14d022bf0c362ff53d65f476c426af16089c4ad8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#pragma once
#include <string>
#include <exception>
#include "Runtime/Graphics/OpenGL.h"
#include "Runtime/Lua/LuaHelper.h"
#include "Runtime/Utilities/UtilMacros.h"
#include "Runtime/Utilities/Assert.h"
#include "runtime/Debug/Log.h"
#include "RenderCommands.h"
// 着色器程序
class Shader : public LuaBind::NativeClass<Shader>
{
public:
Shader()/*throw(ShaderCompileExecption)*/;
Shader(LuaBind::VM*vm)/*throw(ShaderCompileExecption)*/;
Shader(LuaBind::VM*vm, std::string& glsllShader)/*throw(ShaderCompileExecption)*/;
Shader(LuaBind::VM*vm, 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;
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(_Use);
LUA_BIND_DECL_METHOD(_UnUse);
LUA_BIND_DECL_METHOD(_SetVector2);
LUA_BIND_DECL_METHOD(_SetVector3);
LUA_BIND_DECL_METHOD(_SetVector4);
LUA_BIND_DECL_METHOD(_SetMatrix3);
LUA_BIND_DECL_METHOD(_SetMatrix4);
LUA_BIND_DECL_METHOD(_SetTexture);
//LUA_BIND_DECL_METHOD(_SetColor);
};
class ShaderCompileExecption : public std::exception
{
public:
ShaderCompileExecption(const char* what)
: std::exception(what)
{
}
};
|