46 lines
1.1 KiB
C++
46 lines
1.1 KiB
C++
#ifndef __SHADER_H__
|
|
#define __SHADER_H__
|
|
#include <fstream>
|
|
#include <map>
|
|
|
|
#include "util/Common.h"
|
|
#include "util/Log.h"
|
|
|
|
class Shader
|
|
{
|
|
public:
|
|
static Shader& createShader(const string& vertexShaderFilePath, const string& fragmentShaderFilePath);
|
|
|
|
void linkShaders();
|
|
|
|
void addAttribute(const string& attribName);
|
|
|
|
GLuint getUniformLocation(const string& uniformName);
|
|
|
|
void setUniform(const string& name, float x, float y, float z);
|
|
void setUniform(const string& name, const vec3& v);
|
|
void setUniform(const string& name, const dvec3& v);
|
|
void setUniform(const string& name, const vec4& v);
|
|
void setUniform(const string& name, const dvec4& v);
|
|
void setUniform(const string& name, const dmat4& m);
|
|
void setUniform(const string& name, const mat4& m);
|
|
void setUniform(const string& name, const mat3& m);
|
|
void setUniform(const string& name, float val);
|
|
void setUniform(const string& name, int val);
|
|
|
|
void start();
|
|
void stop();
|
|
private:
|
|
int m_attributes;
|
|
|
|
GLuint m_programID;
|
|
GLuint m_vertexShaderID;
|
|
GLuint m_fragmentShaderID;
|
|
|
|
map<string, GLint> m_uniforms;
|
|
|
|
static void compileShader(const string& filePath, GLuint& id);
|
|
};
|
|
|
|
#endif // __SHADER_H__
|