OpenMiner/include/gl/Shader.hpp

58 lines
1.4 KiB
C++
Raw Normal View History

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>
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() = default;
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
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
void addShader(GLenum type, const std::string &filename);
2018-06-05 01:24:54 +02:00
GLint attrib(const std::string &name) const;
GLint uniform(const std::string &name) const;
2018-06-05 01:24:54 +02:00
void enableVertexAttribArray(const std::string &name) const;
void disableVertexAttribArray(const std::string &name) const;
2018-06-05 01:24:54 +02:00
void setUniform(const std::string &name, int n) const;
void setUniform(const std::string &name, const glm::mat4 &matrix) const;
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_