engineer-thesis-WUT/Engine/engine/shader.hpp

36 lines
1.2 KiB
C++

#ifndef SHADER_HPP
#define SHADER_HPP
#include <glad/glad.h> // include glad to get all the required OpenGL headers
#include <string>
#include <fstream>
#include <sstream>
#include <iostream>
class Shader
{
public:
// the program ID
unsigned int ID;
// constructor reads and builds the shader
Shader(const std::string vertexPath, const std::string fragmentPath);
// use/activate the shader
void use();
// utility uniform functions
void setBool(const std::string &name, bool value) const;
void setInt(const std::string &name, int value) const;
void setFloat(const std::string &name, float value) const;
//
private:
unsigned int linkShaderObjectsShaderProgram(const unsigned int vertexShaders, const unsigned int fragmentShader) const;
const char* readFile(const std::string fileName) const;
std::pair<unsigned int, unsigned int> compileShaders(const char* vertexShaderSource, const char* fragmentShaderSource) const;
unsigned int compileShader(const GLenum shaderType, const char *shaderSource) const;
int shaderSuccessful(const unsigned int shader, const bool compilation) const;
void shaderFailedMessage(const unsigned int shader, const bool compilation) const;
};
#endif