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

40 lines
1.5 KiB
C++
Raw Normal View History

2023-03-12 16:24:48 +01:00
// "Copyright [2023] <Krzysztof Rudnicki>"
2023-03-12 17:32:42 +01:00
#ifndef ENGINE_ENGINE_SHADER_HPP_
#define ENGINE_ENGINE_SHADER_HPP_
2022-11-20 23:14:59 +01:00
#include <glad/glad.h>
2022-11-20 23:14:59 +01:00
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
2022-11-20 23:14:59 +01:00
2023-03-12 17:32:42 +01:00
class Shader {
public:
unsigned int ID;
// constructor generates the shader on the fly
// ------------------------------------------------------------------------
Shader(const std::string vertexPath, const std::string fragmentPath);
const std::string fileToShader(const std::string shaderPath);
// 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;
2023-03-12 17:32:42 +01:00
private:
// utility function for checking shader compilation/linking errors.
// ------------------------------------------------------------------------
void checkCompileErrors(unsigned int shader, std::string type);
2023-03-12 17:32:42 +01:00
void compileErrorsMessage(const unsigned int shader, const bool compilation,
const std::string type,
const std::string errorMessage);
2022-11-20 23:14:59 +01:00
};
2023-03-12 17:32:42 +01:00
#endif // ENGINE_ENGINE_SHADER_HPP_