2017-09-02 13:24:07 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-10-20 07:31:42 +00:00
|
|
|
#include <base/detect.h>
|
|
|
|
|
2017-10-20 07:08:49 +00:00
|
|
|
#if defined(CONF_PLATFORM_MACOSX)
|
|
|
|
#include <OpenGL/gl3.h>
|
|
|
|
#else
|
2017-09-02 13:24:07 +00:00
|
|
|
#include "GL/glew.h"
|
2017-10-20 07:08:49 +00:00
|
|
|
#endif
|
2017-09-02 13:24:07 +00:00
|
|
|
|
|
|
|
class CGLSL;
|
|
|
|
|
|
|
|
class CGLSLProgram {
|
|
|
|
public:
|
|
|
|
void CreateProgram();
|
|
|
|
void DeleteProgram();
|
|
|
|
|
|
|
|
bool AddShader(CGLSL* pShader);
|
|
|
|
|
|
|
|
void LinkProgram();
|
|
|
|
void UseProgram();
|
|
|
|
GLuint GetProgramID();
|
|
|
|
|
|
|
|
void DetachShader(CGLSL* pShader);
|
2017-09-14 17:34:14 +00:00
|
|
|
void DetachShaderByID(GLuint ShaderID);
|
|
|
|
void DetachAllShaders();
|
2017-09-02 13:24:07 +00:00
|
|
|
|
|
|
|
//Support various types
|
2017-09-12 18:09:40 +00:00
|
|
|
void SetUniformVec2(int Loc, int Count, const float* Value);
|
2017-09-02 13:24:07 +00:00
|
|
|
void SetUniformVec4(int Loc, int Count, const float* Value);
|
|
|
|
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);
|
|
|
|
|
|
|
|
//for performance reason we do not use SetUniform with using strings... save the Locations of the variables instead
|
|
|
|
int GetUniformLoc(const char* Name);
|
|
|
|
|
|
|
|
CGLSLProgram();
|
2017-09-14 17:34:14 +00:00
|
|
|
virtual ~CGLSLProgram();
|
2017-09-02 13:24:07 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
GLuint m_ProgramID;
|
|
|
|
bool m_IsLinked;
|
|
|
|
};
|
|
|
|
|
2017-09-12 18:09:40 +00:00
|
|
|
class CGLSLTWProgram : public CGLSLProgram {
|
|
|
|
public:
|
2017-09-02 13:24:07 +00:00
|
|
|
int m_LocPos;
|
|
|
|
int m_LocIsTextured;
|
|
|
|
int m_LocTextureSampler;
|
2017-09-12 18:09:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CGLSLQuadProgram : public CGLSLTWProgram {
|
|
|
|
public:
|
2017-09-02 13:24:07 +00:00
|
|
|
|
2017-09-12 18:09:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CGLSLPrimitiveProgram : public CGLSLTWProgram {
|
|
|
|
public:
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
class CGLSLTileProgram : public CGLSLTWProgram {
|
|
|
|
public:
|
|
|
|
int m_LocColor;
|
2017-10-09 16:58:44 +00:00
|
|
|
int m_LocLOD;
|
2017-09-12 18:09:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class CGLSLBorderTileProgram : public CGLSLTileProgram {
|
|
|
|
public:
|
|
|
|
int m_LocOffset;
|
|
|
|
int m_LocDir;
|
|
|
|
int m_LocNum;
|
|
|
|
int m_LocJumpIndex;
|
|
|
|
};
|
|
|
|
|
|
|
|
class CGLSLBorderTileLineProgram : public CGLSLTileProgram {
|
|
|
|
public:
|
|
|
|
int m_LocDir;
|
|
|
|
int m_LocNum;
|
2017-10-20 07:08:49 +00:00
|
|
|
};
|