ddnet/src/engine/client/backend/glsl_shader_compiler.h

61 lines
1.6 KiB
C
Raw Normal View History

#ifndef ENGINE_CLIENT_BACKEND_GLSL_SHADER_COMPILER_H
#define ENGINE_CLIENT_BACKEND_GLSL_SHADER_COMPILER_H
2021-04-30 22:42:37 +00:00
#include <string>
#include <vector>
enum EGLSLShaderCompilerType
{
GLSL_SHADER_COMPILER_TYPE_VERTEX = 0,
GLSL_SHADER_COMPILER_TYPE_FRAGMENT,
2017-10-20 07:08:49 +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;
2021-04-30 22:42:37 +00:00
bool m_IsOpenGLES;
float m_TextureLODBias;
bool m_HasTextureArray;
int m_TextureReplaceType; // @see EGLSLCompilerTextureReplaceType
public:
2021-04-30 22:42:37 +00:00
CGLSLCompiler(int OpenGLVersionMajor, int OpenGLVersionMinor, int OpenGLVersionPatch, bool IsOpenGLES, float TextureLODBias);
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, EGLSLShaderCompilerType Type);
enum EGLSLCompilerTextureReplaceType
{
GLSL_COMPILER_TEXTURE_REPLACE_TYPE_2D = 0,
GLSL_COMPILER_TEXTURE_REPLACE_TYPE_3D,
GLSL_COMPILER_TEXTURE_REPLACE_TYPE_2D_ARRAY,
};
};
#endif