Tesseract-Engine/src/Rendering/Shader.h

37 lines
1.1 KiB
C
Raw Normal View History

// Shader.h
#pragma once
#include <string>
#include <unordered_map>
2024-12-31 21:45:24 +00:00
#include <GL/glew.h> // or appropriate OpenGL headers
#include <glm/glm.hpp> // For glm::mat4
class Shader
{
public:
GLuint ID;
// Constructors
Shader();
2024-12-31 21:45:24 +00:00
Shader(const char *vertexPath, const char *fragmentPath);
~Shader(); // Destructor to clean up shader program
// Use/activate the shader
void Use();
// Utility functions to set uniforms
void SetInt(const std::string &name, int value) const;
void SetFloat(const std::string &name, float value) const;
void SetBool(const std::string &name, bool value) const;
void SetMat4(const std::string &name, const glm::mat4 &mat) const; // For setting 4x4 matrices
2024-12-31 21:45:24 +00:00
void SetSampler2D(const std::string &name, int textureUnit) const;
void SetVec3(const std::string &name, const glm::vec3 &value) const;
private:
// Caching uniform locations for performance
mutable std::unordered_map<std::string, GLint> uniformLocationCache;
// Retrieves the location of a uniform variable, with caching
GLint GetUniformLocation(const std::string &name) const;
};