40 lines
995 B
C++
40 lines
995 B
C++
#ifndef _H_SHADER_H
|
|
#define _H_SHADER_H
|
|
|
|
#include <thirdparty/glad/glad.h>
|
|
#include <fstream>
|
|
#include <string>
|
|
|
|
class Shader
|
|
{
|
|
protected:
|
|
bool compileAndLink(const char *vSource, const char *fSource);
|
|
std::string vertexPath;
|
|
std::string fragmentPath;
|
|
bool valid;
|
|
Shader();
|
|
public:
|
|
unsigned int ID;
|
|
Shader(const char* vertPath, const char* fragPath);
|
|
|
|
void use() { glUseProgram(ID); }
|
|
void setFloat(const std::string& name, float value);
|
|
void setFloatArray(const std::string & name, size_t count, const float* value);
|
|
void setIntArray(const std::string & name, size_t count, const int* value);
|
|
void setInt(const std::string& name, int value);
|
|
void setBool(const std::string& name, bool value);
|
|
void setVec2(const std::string& name, const float* value);
|
|
void setMatrix4f(const std::string& name, const float* value);
|
|
|
|
bool isValid() { return valid; }
|
|
|
|
virtual ~Shader();
|
|
};
|
|
|
|
class GenericShader : public Shader
|
|
{
|
|
public:
|
|
GenericShader() : Shader() {};
|
|
};
|
|
|
|
#endif // _H_SHADER_H
|