2014-12-15 16:47:30 +01:00
|
|
|
/*
|
|
|
|
* =====================================================================================
|
|
|
|
*
|
|
|
|
* Filename: Shader.hpp
|
|
|
|
*
|
2018-06-05 01:24:54 +02:00
|
|
|
* Description:
|
2014-12-15 16:47:30 +01:00
|
|
|
*
|
|
|
|
* Version: 1.0
|
|
|
|
* Created: 15/12/2014 16:30:20
|
|
|
|
* Revision: none
|
|
|
|
* Compiler: gcc
|
|
|
|
*
|
|
|
|
* Author: Quentin BAZIN, <quent42340@gmail.com>
|
2018-06-05 01:24:54 +02:00
|
|
|
* Company:
|
2014-12-15 16:47:30 +01:00
|
|
|
*
|
|
|
|
* =====================================================================================
|
|
|
|
*/
|
|
|
|
#ifndef SHADER_HPP_
|
|
|
|
#define SHADER_HPP_
|
|
|
|
|
2014-12-18 07:02:48 +01:00
|
|
|
#include <string>
|
2015-02-06 01:44:16 +01:00
|
|
|
#include <vector>
|
2014-12-18 07:02:48 +01:00
|
|
|
|
|
|
|
#include <glm/glm.hpp>
|
|
|
|
|
2014-12-15 16:47:30 +01:00
|
|
|
#include "OpenGL.hpp"
|
|
|
|
|
|
|
|
class Shader {
|
|
|
|
public:
|
|
|
|
Shader();
|
|
|
|
Shader(const char *vertexFilename, const char *fragementFilename);
|
|
|
|
~Shader();
|
2018-06-05 01:24:54 +02:00
|
|
|
|
2014-12-15 16:47:30 +01:00
|
|
|
void loadFromFile(const char *vertexFilename, const char *fragementFilename);
|
2018-06-05 01:24:54 +02:00
|
|
|
|
2015-02-06 01:44:16 +01:00
|
|
|
void createProgram();
|
|
|
|
void linkProgram();
|
2018-06-05 01:24:54 +02:00
|
|
|
|
2015-02-06 01:44:16 +01:00
|
|
|
void addShader(GLenum type, const char *filename);
|
2018-06-05 01:24:54 +02:00
|
|
|
|
2014-12-18 07:02:48 +01:00
|
|
|
GLint attrib(std::string name);
|
|
|
|
GLint uniform(std::string name);
|
2018-06-05 01:24:54 +02:00
|
|
|
|
2014-12-18 07:02:48 +01:00
|
|
|
void enableVertexAttribArray(std::string name);
|
|
|
|
void disableVertexAttribArray(std::string name);
|
2018-06-05 01:24:54 +02:00
|
|
|
|
2014-12-18 07:02:48 +01:00
|
|
|
void setUniform(std::string name, int n);
|
|
|
|
void setUniform(std::string name, const glm::mat4 &matrix);
|
2018-06-05 01:24:54 +02:00
|
|
|
|
2014-12-15 16:47:30 +01:00
|
|
|
static void bind(const Shader *shader);
|
2018-06-05 01:24:54 +02:00
|
|
|
|
2014-12-15 16:47:30 +01:00
|
|
|
GLint program() const { return m_program; }
|
2018-06-05 01:24:54 +02:00
|
|
|
|
2014-12-15 16:47:30 +01:00
|
|
|
private:
|
2015-02-06 01:44:16 +01:00
|
|
|
std::vector<GLuint> m_vertexShaders;
|
|
|
|
std::vector<GLuint> m_fragmentShaders;
|
2014-12-15 16:47:30 +01:00
|
|
|
GLuint m_program;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SHADER_HPP_
|