blob: 8d5fc0e256ff19e1dc3879d396ac26d3a1fa84c7 (
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
|
#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)
{
}
};
|