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
|
|
|
*
|
|
|
|
* Created: 15/12/2014 16:30:20
|
|
|
|
*
|
|
|
|
* Author: Quentin BAZIN, <quent42340@gmail.com>
|
|
|
|
*
|
|
|
|
* =====================================================================================
|
|
|
|
*/
|
|
|
|
#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();
|
2015-07-17 17:08:53 +02:00
|
|
|
Shader(const std::string &vertexFilename, const std::string &fragementFilename);
|
2014-12-15 16:47:30 +01:00
|
|
|
~Shader();
|
2018-06-05 01:24:54 +02:00
|
|
|
|
2015-07-17 17:08:53 +02:00
|
|
|
void loadFromFile(const std::string &vertexFilename, const std::string &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-07-17 17:08:53 +02:00
|
|
|
void addShader(GLenum type, const std::string &filename);
|
2018-06-05 01:24:54 +02:00
|
|
|
|
2015-07-17 17:08:53 +02:00
|
|
|
GLint attrib(const std::string &name);
|
|
|
|
GLint uniform(const std::string &name);
|
2018-06-05 01:24:54 +02:00
|
|
|
|
2015-07-17 17:08:53 +02:00
|
|
|
void enableVertexAttribArray(const std::string &name);
|
|
|
|
void disableVertexAttribArray(const std::string &name);
|
2018-06-05 01:24:54 +02:00
|
|
|
|
2015-07-17 17:08:53 +02:00
|
|
|
void setUniform(const std::string &name, int n);
|
|
|
|
void setUniform(const 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;
|
2018-06-05 16:51:58 +02:00
|
|
|
|
2014-12-15 16:47:30 +01:00
|
|
|
GLuint m_program;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // SHADER_HPP_
|