1 | #ifndef ENGINE_CLIENT_BACKEND_GLSL_SHADER_COMPILER_H |
2 | #define ENGINE_CLIENT_BACKEND_GLSL_SHADER_COMPILER_H |
3 | |
4 | #include <string> |
5 | #include <vector> |
6 | |
7 | enum EGLSLShaderCompilerType |
8 | { |
9 | GLSL_SHADER_COMPILER_TYPE_VERTEX = 0, |
10 | GLSL_SHADER_COMPILER_TYPE_FRAGMENT, |
11 | }; |
12 | |
13 | class CGLSLCompiler |
14 | { |
15 | private: |
16 | friend class CGLSL; |
17 | |
18 | struct SGLSLCompilerDefine |
19 | { |
20 | SGLSLCompilerDefine(const std::string &DefineName, const std::string &DefineValue) |
21 | { |
22 | m_DefineName = DefineName; |
23 | m_DefineValue = DefineValue; |
24 | } |
25 | std::string m_DefineName; |
26 | std::string m_DefineValue; |
27 | }; |
28 | |
29 | std::vector<SGLSLCompilerDefine> m_vDefines; |
30 | |
31 | int m_OpenGLVersionMajor; |
32 | int m_OpenGLVersionMinor; |
33 | int m_OpenGLVersionPatch; |
34 | |
35 | bool m_IsOpenGLES; |
36 | |
37 | float m_TextureLODBias; |
38 | |
39 | bool m_HasTextureArray; |
40 | int m_TextureReplaceType; // @see EGLSLCompilerTextureReplaceType |
41 | public: |
42 | CGLSLCompiler(int OpenGLVersionMajor, int OpenGLVersionMinor, int OpenGLVersionPatch, bool IsOpenGLES, float TextureLODBias); |
43 | void SetHasTextureArray(bool TextureArray) { m_HasTextureArray = TextureArray; } |
44 | void SetTextureReplaceType(int TextureReplaceType) { m_TextureReplaceType = TextureReplaceType; } |
45 | |
46 | void AddDefine(const std::string &DefineName, const std::string &DefineValue); |
47 | void AddDefine(const char *pDefineName, const char *pDefineValue); |
48 | void ClearDefines(); |
49 | |
50 | void ParseLine(std::string &Line, const char *pReadLine, EGLSLShaderCompilerType Type); |
51 | |
52 | enum EGLSLCompilerTextureReplaceType |
53 | { |
54 | GLSL_COMPILER_TEXTURE_REPLACE_TYPE_2D = 0, |
55 | GLSL_COMPILER_TEXTURE_REPLACE_TYPE_3D, |
56 | GLSL_COMPILER_TEXTURE_REPLACE_TYPE_2D_ARRAY, |
57 | }; |
58 | }; |
59 | |
60 | #endif |
61 | |