You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

57 lines
2.0 KiB

#ifndef SHADER_H
#define SHADER_H
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include "ExternalLib/glad.h"
/********************************************************
* *
* ANNOUNCEMENT : WHY IS SHADER CLASS A BLACK BOX ? *
* *
* Shaders should always be ephemere objects as they *
* stack up quickly in the memory, thus this class *
* should never be instantiated anywhere else than *
* in ShaderProgram *
* *
* Even like that, Shaders should only live during *
* the ShaderProgram Linking period *
********************************************************/
enum ShaderType
{
GEOMETRY,
FRAGMENT,
VERTEX,
UNKNOWN,
};
class Shader
{
public: // TODO hide those and declare ShaderProgram as friend class
/***** Constructors *****/
Shader(GLenum const &shaderType);
~Shader();
/***** Methods *****/
bool loadFromFile(std::string const &filename); // Load Shader code from file
void unload(); // Unload shdare from memory and GPU
bool compile(); // Compile Shader
/***** Getters *****/
GLuint getId();
ShaderType getType();
std::string getSource();
std::string getSourceLocation();
private:
/***** Members *****/
GLuint shaderId; // shaderID used to access shader on the GPU size
ShaderType shaderType; // describe if Shader is a vertex/fragment/geometry shader
std::string shaderSourceCode; // shader source code
std::string shaderSourceCodeLocation; // shader source code file path
};
#endif /* SHADER_H */