2018-02-12 22:14:14 +00:00
|
|
|
#ifndef ENGINE_CLIENT_OPENGL_SL_H
|
|
|
|
#define ENGINE_CLIENT_OPENGL_SL_H
|
2017-09-02 13:24:07 +00:00
|
|
|
|
2018-02-12 22:14:14 +00:00
|
|
|
#include <GL/glew.h>
|
2020-08-29 10:10:38 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
class CGLSLCompiler;
|
2017-09-02 13:24:07 +00:00
|
|
|
|
|
|
|
class CGLSL {
|
|
|
|
public:
|
2020-08-29 10:10:38 +00:00
|
|
|
bool LoadShader(CGLSLCompiler* pCompiler, class IStorage *pStorage, const char *pFile, int Type);
|
2017-09-02 13:24:07 +00:00
|
|
|
void DeleteShader();
|
|
|
|
|
|
|
|
bool IsLoaded();
|
|
|
|
GLuint GetShaderID();
|
|
|
|
|
|
|
|
CGLSL();
|
2017-09-14 17:35:31 +00:00
|
|
|
virtual ~CGLSL();
|
2017-09-02 13:24:07 +00:00
|
|
|
private:
|
|
|
|
GLuint m_ShaderID;
|
|
|
|
int m_Type;
|
|
|
|
bool m_IsLoaded;
|
2017-10-20 07:08:49 +00:00
|
|
|
};
|
2018-02-12 22:14:14 +00:00
|
|
|
|
2020-08-29 10:10:38 +00:00
|
|
|
class CGLSLCompiler
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
friend class CGLSL;
|
|
|
|
|
|
|
|
struct SGLSLCompilerDefine
|
|
|
|
{
|
|
|
|
SGLSLCompilerDefine(const std::string& DefineName, const std::string& DefineValue)
|
|
|
|
{
|
|
|
|
m_DefineName = DefineName;
|
|
|
|
m_DefineValue = DefineValue;
|
|
|
|
}
|
|
|
|
std::string m_DefineName;
|
|
|
|
std::string m_DefineValue;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::vector<SGLSLCompilerDefine> m_Defines;
|
|
|
|
|
|
|
|
int m_OpenGLVersionMajor;
|
|
|
|
int m_OpenGLVersionMinor;
|
|
|
|
int m_OpenGLVersionPatch;
|
|
|
|
|
|
|
|
bool m_HasTextureArray;
|
|
|
|
int m_TextureReplaceType; // @see EGLSLCompilerTextureReplaceType
|
|
|
|
public:
|
|
|
|
CGLSLCompiler(int OpenGLVersionMajor, int OpenGLVersionMinor, int OpenGLVersionPatch);
|
|
|
|
void SetHasTextureArray(bool TextureArray) { m_HasTextureArray = TextureArray; }
|
|
|
|
void SetTextureReplaceType(int TextureReplaceType) { m_TextureReplaceType = TextureReplaceType; }
|
|
|
|
|
|
|
|
void AddDefine(const std::string& DefineName, const std::string& DefineValue);
|
|
|
|
void AddDefine(const char* pDefineName, const char* pDefineValue);
|
|
|
|
void ClearDefines();
|
|
|
|
|
|
|
|
void ParseLine(std::string& Line, const char* pReadLine, int Type);
|
|
|
|
|
|
|
|
enum EGLSLCompilerTextureReplaceType
|
|
|
|
{
|
|
|
|
GLSL_COMPILER_TEXTURE_REPLACE_TYPE_2D = 0,
|
|
|
|
GLSL_COMPILER_TEXTURE_REPLACE_TYPE_3D,
|
|
|
|
GLSL_COMPILER_TEXTURE_REPLACE_TYPE_2D_ARRAY,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-02-12 22:14:14 +00:00
|
|
|
#endif // ENGINE_CLIENT_OPENGL_SL_H
|