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
7class CGLSLCompiler
8{
9 friend class CGLSL;
10
11public:
12 enum class EShaderType
13 {
14 VERTEX,
15 FRAGMENT,
16 };
17
18 enum class ETextureReplaceType
19 {
20 TEXTURE_2D,
21 TEXTURE_3D,
22 TEXTURE_2D_ARRAY,
23 };
24
25 CGLSLCompiler(int OpenGLVersionMajor, int OpenGLVersionMinor, int OpenGLVersionPatch, bool IsOpenGLES, float TextureLODBias);
26 void SetHasTextureArray(bool TextureArray) { m_HasTextureArray = TextureArray; }
27 void SetTextureReplaceType(ETextureReplaceType TextureReplaceType) { m_TextureReplaceType = TextureReplaceType; }
28
29 void AddDefine(const char *pDefineName, const char *pDefineValue);
30 void ClearDefines();
31
32 void ParseLine(std::string &Line, const char *pReadLine, EShaderType Type) const;
33
34private:
35 void ParseLineOldOpenGL(std::string &Line, const char *pReadLine, EShaderType Type) const;
36 void ParseLineGLES(std::string &Line, const char *pReadLine) const;
37
38 class CDefine
39 {
40 public:
41 CDefine(const char *pDefineName, const char *pDefineValue)
42 {
43 m_DefineName = pDefineName;
44 m_DefineValue = pDefineValue;
45 }
46 std::string m_DefineName;
47 std::string m_DefineValue;
48 };
49
50 std::vector<CDefine> m_vDefines;
51
52 int m_OpenGLVersionMajor;
53 int m_OpenGLVersionMinor;
54 int m_OpenGLVersionPatch;
55
56 bool m_IsOpenGLES;
57
58 float m_TextureLODBias;
59
60 bool m_HasTextureArray;
61 ETextureReplaceType m_TextureReplaceType;
62};
63
64#endif
65