2018-02-12 22:14:14 +00:00
|
|
|
#ifndef ENGINE_CLIENT_OPENGL_SL_PROGRAM_H
|
|
|
|
#define ENGINE_CLIENT_OPENGL_SL_PROGRAM_H
|
2017-09-02 13:24:07 +00:00
|
|
|
|
2018-02-12 22:14:14 +00:00
|
|
|
#include <GL/glew.h>
|
2017-09-02 13:24:07 +00:00
|
|
|
|
|
|
|
class CGLSL;
|
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
class CGLSLProgram
|
|
|
|
{
|
2017-09-02 13:24:07 +00:00
|
|
|
public:
|
|
|
|
void CreateProgram();
|
|
|
|
void DeleteProgram();
|
2020-09-26 19:41:58 +00:00
|
|
|
|
|
|
|
bool AddShader(CGLSL *pShader);
|
|
|
|
|
2017-09-02 13:24:07 +00:00
|
|
|
void LinkProgram();
|
|
|
|
void UseProgram();
|
|
|
|
GLuint GetProgramID();
|
2020-09-26 19:41:58 +00:00
|
|
|
|
|
|
|
void DetachShader(CGLSL *pShader);
|
2017-09-14 17:34:14 +00:00
|
|
|
void DetachShaderByID(GLuint ShaderID);
|
|
|
|
void DetachAllShaders();
|
2020-09-26 19:41:58 +00:00
|
|
|
|
|
|
|
//Support various types
|
2020-08-29 10:10:38 +00:00
|
|
|
void SetUniformVec2(int Loc, int Count, const float *pValue);
|
|
|
|
void SetUniformVec4(int Loc, int Count, const float *pValue);
|
2017-09-02 13:24:07 +00:00
|
|
|
void SetUniform(int Loc, const int Value);
|
|
|
|
void SetUniform(int Loc, const unsigned int Value);
|
|
|
|
void SetUniform(int Loc, const bool Value);
|
|
|
|
void SetUniform(int Loc, const float Value);
|
2020-08-29 10:10:38 +00:00
|
|
|
void SetUniform(int Loc, int Count, const float *pValues);
|
2020-09-26 19:41:58 +00:00
|
|
|
|
2017-09-02 13:24:07 +00:00
|
|
|
//for performance reason we do not use SetUniform with using strings... save the Locations of the variables instead
|
2020-09-26 19:41:58 +00:00
|
|
|
int GetUniformLoc(const char *Name);
|
|
|
|
|
2017-09-02 13:24:07 +00:00
|
|
|
CGLSLProgram();
|
2017-09-14 17:34:14 +00:00
|
|
|
virtual ~CGLSLProgram();
|
2020-09-26 19:41:58 +00:00
|
|
|
|
2017-09-02 13:24:07 +00:00
|
|
|
protected:
|
|
|
|
GLuint m_ProgramID;
|
|
|
|
bool m_IsLinked;
|
|
|
|
};
|
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
class CGLSLTWProgram : public CGLSLProgram
|
|
|
|
{
|
2018-03-13 20:47:45 +00:00
|
|
|
public:
|
2020-09-26 19:41:58 +00:00
|
|
|
CGLSLTWProgram() :
|
|
|
|
m_LocPos(-1), m_LocIsTextured(-1), m_LocTextureSampler(-1), m_LastTextureSampler(-1), m_LastIsTextured(-1)
|
2018-03-21 14:49:15 +00:00
|
|
|
{
|
|
|
|
m_LastScreen[0] = m_LastScreen[1] = m_LastScreen[2] = m_LastScreen[3] = -1.f;
|
|
|
|
}
|
2018-03-13 20:47:45 +00:00
|
|
|
|
2017-09-02 13:24:07 +00:00
|
|
|
int m_LocPos;
|
|
|
|
int m_LocIsTextured;
|
|
|
|
int m_LocTextureSampler;
|
2018-03-13 20:47:45 +00:00
|
|
|
|
|
|
|
int m_LastTextureSampler;
|
|
|
|
int m_LastIsTextured;
|
2018-03-21 14:49:15 +00:00
|
|
|
float m_LastScreen[4];
|
2017-09-12 18:09:40 +00:00
|
|
|
};
|
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
class CGLSLTextProgram : public CGLSLTWProgram
|
|
|
|
{
|
2017-09-12 18:09:40 +00:00
|
|
|
public:
|
2020-09-26 19:41:58 +00:00
|
|
|
CGLSLTextProgram() :
|
|
|
|
CGLSLTWProgram()
|
2018-03-13 20:47:45 +00:00
|
|
|
{
|
|
|
|
m_LastColor[0] = m_LastColor[1] = m_LastColor[2] = m_LastColor[3] = -1.f;
|
|
|
|
m_LastOutlineColor[0] = m_LastOutlineColor[1] = m_LastOutlineColor[2] = m_LastOutlineColor[3] = -1.f;
|
|
|
|
m_LastTextSampler = m_LastTextOutlineSampler = -1;
|
|
|
|
m_LastTextureSize = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int m_LocColor;
|
|
|
|
int m_LocOutlineColor;
|
|
|
|
int m_LocTextSampler;
|
|
|
|
int m_LocTextOutlineSampler;
|
|
|
|
int m_LocTextureSize;
|
|
|
|
|
|
|
|
float m_LastColor[4];
|
|
|
|
float m_LastOutlineColor[4];
|
|
|
|
int m_LastTextSampler;
|
|
|
|
int m_LastTextOutlineSampler;
|
|
|
|
int m_LastTextureSize;
|
2017-09-12 18:09:40 +00:00
|
|
|
};
|
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
class CGLSLPrimitiveProgram : public CGLSLTWProgram
|
|
|
|
{
|
2017-09-12 18:09:40 +00:00
|
|
|
public:
|
2018-03-13 20:47:45 +00:00
|
|
|
};
|
|
|
|
|
2020-10-20 16:45:03 +00:00
|
|
|
class CGLSLPrimitiveExProgram : public CGLSLTWProgram
|
2020-09-26 19:41:58 +00:00
|
|
|
{
|
2018-03-13 20:47:45 +00:00
|
|
|
public:
|
2020-10-20 16:45:03 +00:00
|
|
|
CGLSLPrimitiveExProgram() :
|
2020-09-26 19:41:58 +00:00
|
|
|
CGLSLTWProgram()
|
2018-03-13 20:47:45 +00:00
|
|
|
{
|
|
|
|
m_LastRotation = 0.f;
|
|
|
|
m_LastCenter[0] = m_LastCenter[1] = 0.f;
|
|
|
|
m_LastVertciesColor[0] = m_LastVertciesColor[1] = m_LastVertciesColor[2] = m_LastVertciesColor[3] = -1.f;
|
|
|
|
}
|
|
|
|
|
|
|
|
int m_LocRotation;
|
|
|
|
int m_LocCenter;
|
|
|
|
int m_LocVertciesColor;
|
|
|
|
|
|
|
|
float m_LastRotation;
|
|
|
|
float m_LastCenter[2];
|
|
|
|
float m_LastVertciesColor[4];
|
|
|
|
};
|
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
class CGLSLSpriteMultipleProgram : public CGLSLTWProgram
|
|
|
|
{
|
2018-03-13 20:47:45 +00:00
|
|
|
public:
|
2020-09-26 19:41:58 +00:00
|
|
|
CGLSLSpriteMultipleProgram() :
|
|
|
|
CGLSLTWProgram()
|
2018-03-13 20:47:45 +00:00
|
|
|
{
|
|
|
|
m_LastCenter[0] = m_LastCenter[1] = 0.f;
|
|
|
|
m_LastVertciesColor[0] = m_LastVertciesColor[1] = m_LastVertciesColor[2] = m_LastVertciesColor[3] = -1.f;
|
|
|
|
}
|
|
|
|
|
|
|
|
int m_LocRSP;
|
|
|
|
int m_LocCenter;
|
|
|
|
int m_LocVertciesColor;
|
|
|
|
|
|
|
|
float m_LastCenter[2];
|
|
|
|
float m_LastVertciesColor[4];
|
|
|
|
};
|
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
class CGLSLQuadProgram : public CGLSLTWProgram
|
|
|
|
{
|
2018-03-13 20:47:45 +00:00
|
|
|
public:
|
2020-08-29 10:10:38 +00:00
|
|
|
int m_LocColors;
|
|
|
|
int m_LocOffsets;
|
|
|
|
int m_LocRotations;
|
2017-09-12 18:09:40 +00:00
|
|
|
};
|
|
|
|
|
2020-09-26 19:41:58 +00:00
|
|
|
class CGLSLTileProgram : public CGLSLTWProgram
|
|
|
|
{
|
2017-09-12 18:09:40 +00:00
|
|
|
public:
|
2020-09-26 19:41:58 +00:00
|
|
|
CGLSLTileProgram() :
|
|
|
|
m_LocColor(-1), m_LocOffset(-1), m_LocDir(-1), m_LocNum(-1), m_LocJumpIndex(-1) {}
|
2020-08-26 18:01:32 +00:00
|
|
|
|
2020-08-29 10:10:38 +00:00
|
|
|
int m_LocColor;
|
2017-09-12 18:09:40 +00:00
|
|
|
int m_LocOffset;
|
|
|
|
int m_LocDir;
|
|
|
|
int m_LocNum;
|
|
|
|
int m_LocJumpIndex;
|
|
|
|
};
|
|
|
|
|
2018-02-12 22:14:14 +00:00
|
|
|
#endif // ENGINE_CLIENT_OPENGL_SL_PROGRAM_H
|