#ifndef ShaderProgram_h__ #define ShaderProgram_h__ #include #include #include #include #include #include #include "ResourceManager.h" class Shader { public: static GLuint CompileShader(GLenum shaderType, std::string fileName); Shader(GLenum shaderType, std::string fileName); virtual ~Shader(); GLuint Compile(); GLenum GetType() const; std::string GetFileName() const; GLuint GetHandle() const; bool IsCompiled() const; protected: GLenum m_ShaderType; std::string m_FileName; GLint m_ShaderHandle; }; template class ShaderType : public Shader { public: ShaderType(std::string fileName) : Shader(SHADERTYPE, fileName) { } }; class VertexShader : public ShaderType { public: VertexShader(std::string fileName) : ShaderType(fileName) { } }; class FragmentShader : public ShaderType { public: FragmentShader(std::string fileName) : ShaderType(fileName) { } }; class GeometryShader : public ShaderType { public: GeometryShader(std::string fileName) : ShaderType(fileName) { } }; class ShaderProgram : public Resource { public: ShaderProgram() : m_ShaderProgramHandle(0) { } ShaderProgram(std::string folderPath) : m_ShaderProgramHandle(0) { } ~ShaderProgram(); void AddShader(std::shared_ptr shader); void BindFragDataLocation(int colorNumber, std::string name); void Compile(); GLuint Link(); GLuint GetHandle(); operator GLuint() const { return m_ShaderProgramHandle; } void Bind(); void Unbind(); private: GLuint m_ShaderProgramHandle; std::vector> m_Shaders; void LoadFromFolder(std::string folderPath); }; #endif // ShaderProgram_h__