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.
 
 
 
 
 
 

47 lines
2.5 KiB

#ifndef SHADER_PROGRAM_H
#define SHADER_PROGRAM_H
#include "Shader.h"
#include "ShaderProgram.h"
#include <list>
#include "ExternalLib/glad.h"
/*******************************************************************
* ShaderProgram is an abstraction of OpenGL shader model *
* *
* It provides easy to build, link, use methods for a more *
* fluid and convenient usage of shaders *
* *
* A ShaderProgram requires AT LEAST one vertex and one fragment *
* shader to be functional, but it can stores many more *
*******************************************************************/
//TODO Verify that shaders are correctly destroyed after linkage
class ShaderProgram
{
public:
ShaderProgram(); // Initialize empty lists and programId = 0
~ShaderProgram(); // Empty lists and set program Id = 0
void initGL(); // initialize openGl ShaderProgram / get programId
void destroyGL(); // destroy openGL ShaderProgram associated to programId
void attachShaders(std::string const &shaderDirectory); // Load, attach and compile
// every shader available within shaderDirector
void detachShaders(); // Detach and set for deletion every shaders listed
bool linkProgram(); // Link every shader on the lists to ShaderProgram, compile the program
// and then detach and delete associated Shaders leftovers
void enable(); // Enable ShaderProgram as current used ShaderProgram
void disable(); // Set current use ShaderProgram to 0
GLuint getId() const; // returns programId
bool reload(); // reload, recompile, relink current shader(s)
private:
GLuint programId; // GLuint referencing GPU openGL shader program
std::list<Shader> vertexShaderList; // list of linked and compiled vertex shader associated to this
std::list<Shader> fragmentShaderList; // list of linked and compiled fragment shader associated to this
std::list<Shader> geometryShaderList; // list of linked and compiled geometry shader associated to this
std::string shaderDirectoryPath; // folder storing every shader(s)
};
#endif /* SHADER_PROGRAM_H */