2016-07-26 19:27:02 +00:00
|
|
|
#ifndef __GL_SHADERPROGRAM_H
|
|
|
|
#define __GL_SHADERPROGRAM_H
|
|
|
|
|
|
|
|
#include "gl_shader.h"
|
|
|
|
|
|
|
|
class FShaderProgram
|
|
|
|
{
|
|
|
|
public:
|
2016-08-25 23:40:28 +00:00
|
|
|
FShaderProgram();
|
2016-07-26 19:27:02 +00:00
|
|
|
~FShaderProgram();
|
|
|
|
|
|
|
|
enum ShaderType
|
|
|
|
{
|
|
|
|
Vertex,
|
|
|
|
Fragment,
|
|
|
|
NumShaderTypes
|
|
|
|
};
|
|
|
|
|
2016-07-29 19:31:20 +00:00
|
|
|
void Compile(ShaderType type, const char *lumpName, const char *defines, int maxGlslVersion);
|
|
|
|
void Compile(ShaderType type, const char *name, const FString &code, const char *defines, int maxGlslVersion);
|
2016-07-26 19:27:02 +00:00
|
|
|
void SetFragDataLocation(int index, const char *name);
|
|
|
|
void Link(const char *name);
|
|
|
|
void SetAttribLocation(int index, const char *name);
|
|
|
|
void Bind();
|
|
|
|
|
|
|
|
operator GLuint() const { return mProgram; }
|
|
|
|
explicit operator bool() const { return mProgram != 0; }
|
|
|
|
|
|
|
|
private:
|
2016-08-25 23:40:28 +00:00
|
|
|
FShaderProgram(const FShaderProgram &) = delete;
|
|
|
|
FShaderProgram &operator=(const FShaderProgram &) = delete;
|
|
|
|
|
2016-07-29 19:31:20 +00:00
|
|
|
static FString PatchShader(ShaderType type, const FString &code, const char *defines, int maxGlslVersion);
|
|
|
|
|
2016-07-26 19:27:02 +00:00
|
|
|
void CreateShader(ShaderType type);
|
|
|
|
FString GetShaderInfoLog(GLuint handle);
|
|
|
|
FString GetProgramInfoLog(GLuint handle);
|
|
|
|
|
|
|
|
GLuint mProgram = 0;
|
|
|
|
GLuint mShaders[NumShaderTypes];
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|