2015-07-26 21:39:49 +00:00
|
|
|
#ifndef CSHADER_H
|
|
|
|
#define CSHADER_H
|
|
|
|
|
|
|
|
#include <gl/glew.h>
|
2015-11-24 06:08:31 +00:00
|
|
|
#include <Common/TString.h>
|
2015-07-26 21:39:49 +00:00
|
|
|
|
|
|
|
class CShader
|
|
|
|
{
|
|
|
|
bool mVertexShaderExists;
|
|
|
|
bool mPixelShaderExists;
|
|
|
|
bool mProgramExists;
|
|
|
|
GLuint mVertexShader;
|
|
|
|
GLuint mPixelShader;
|
|
|
|
GLuint mProgram;
|
|
|
|
|
|
|
|
GLuint mMVPBlockIndex;
|
|
|
|
GLuint mVertexBlockIndex;
|
|
|
|
GLuint mPixelBlockIndex;
|
|
|
|
GLuint mLightBlockIndex;
|
|
|
|
|
|
|
|
static CShader* spCurrentShader;
|
|
|
|
|
|
|
|
public:
|
|
|
|
CShader();
|
|
|
|
CShader(const char* kpVertexSource, const char* kpPixelSource);
|
|
|
|
~CShader();
|
|
|
|
bool CompileVertexSource(const char* kpSource);
|
|
|
|
bool CompilePixelSource(const char* kpSource);
|
|
|
|
bool LinkShaders();
|
|
|
|
bool IsValidProgram();
|
|
|
|
GLuint GetProgramID();
|
2015-11-24 06:08:31 +00:00
|
|
|
GLuint GetUniformLocation(const char* kpUniform);
|
|
|
|
GLuint GetUniformBlockIndex(const char* kpUniformBlock);
|
2015-07-26 21:39:49 +00:00
|
|
|
void SetCurrent();
|
|
|
|
|
|
|
|
// Static
|
2015-11-24 06:08:31 +00:00
|
|
|
static CShader* FromResourceFile(const TString& ShaderName);
|
2015-07-26 21:39:49 +00:00
|
|
|
static CShader* CurrentShader();
|
|
|
|
static void KillCachedShader();
|
|
|
|
|
|
|
|
private:
|
2015-11-24 06:08:31 +00:00
|
|
|
void DumpShaderSource(GLuint Shader, const TString& Out);
|
2015-07-26 21:39:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CSHADER_H
|