engineer-thesis-WUT/breakout/shader.hpp

42 lines
1.8 KiB
C++
Raw Normal View History

// Copyright [2023] Krzysztof Rudnicki
2023-07-06 17:35:25 +02:00
#ifndef HOME_KUCHY_ENGINEER_THESIS_WUT_BREAKOUT_SHADER_HPP
#define HOME_KUCHY_ENGINEER_THESIS_WUT_BREAKOUT_SHADER_HPP
2023-04-02 17:59:15 +02:00
#include "../dependencies/include/glad/glad.h"
#include "../dependencies/include/glm/glm/glm.hpp"
#include "../dependencies/include/glm/glm/gtc/type_ptr.hpp"
2023-04-02 17:59:15 +02:00
// General purpose shader object. Compiles from file, generates
// compile/link-time error messages and hosts several utility
2023-04-02 17:59:15 +02:00
// functions for easy management.
class Shader {
2023-07-06 17:35:25 +02:00
public:
// state
unsigned int ID{};
// constructor
Shader() = default;
// sets the current shader as active
auto Use() -> Shader &;
// compiles the shader from given source code
void Compile(const char *vertexSource, const char *fragmentSource,
const char *geometrySource);
// note: geometrysource code is optional
// utility functions
void SetFloat(const char *name, float value, bool useShader);
void SetInteger(const char *name, int value, bool useShader);
void SetVector2f(const char *name, float x, float y, bool useShader);
void SetVector2f(const char *name, const glm::vec2 &value, bool useShader);
void SetVector3f(const char *name, float x, float y, float z, bool useShader);
void SetVector3f(const char *name, const glm::vec3 &value, bool useShader);
void SetVector4f(const char *name, float x, float y, float z, float w,
bool useShader);
void SetVector4f(const char *name, const glm::vec4 &value, bool useShader);
void SetMatrix4(const char *name, const glm::mat4 &matrix, bool useShader);
2023-07-06 17:35:25 +02:00
private:
// checks if compilation or linking failed and if so, print the error logs
static void checkCompileErrors(unsigned int object, const std::string &type);
2023-04-02 17:59:15 +02:00
};
2023-07-06 17:35:25 +02:00
#endif // HOME_KUCHY_ENGINEER_THESIS_WUT_BREAKOUT_SHADER_HPP