51 lines
1.5 KiB
C++
51 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <glad/glad.h>
|
|
#include <string>
|
|
#include <climits>
|
|
#include <glm/glm.hpp>
|
|
|
|
struct Material {
|
|
glm::vec3 ambient{0.1f,0.1f,0.1f};
|
|
float shininess{32.0f};
|
|
unsigned int diffuseMap = 0;
|
|
unsigned int specularMap = 0;
|
|
};
|
|
|
|
struct Light {
|
|
glm::vec3 position;
|
|
glm::vec3 ambient;
|
|
glm::vec3 diffuse;
|
|
glm::vec3 specular;
|
|
};
|
|
|
|
class Shader
|
|
{
|
|
public:
|
|
unsigned int ID = UINT_MAX;
|
|
|
|
Shader(const char* vertexPath, const char* fragmentPath);
|
|
unsigned int load_shader(const std::string& filename, GLenum shader_type);
|
|
void use() const;
|
|
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;
|
|
void setVec4(const std::string &name, float v1, float v2, float v3, float v4) const;
|
|
void setVec4(const std::string &name, const glm::vec4& value) const;
|
|
void setVec3(const std::string &name, float v1, float v2, float v3) const;
|
|
void setVec3(const std::string &name, const glm::vec3& value) const;
|
|
void setMat4(const std::string &name, const glm::mat4& what) const;
|
|
void cleanup();
|
|
|
|
void applyMaterial(const Material& material) {
|
|
setVec3("material.ambient", material.ambient);
|
|
setFloat("material.shininess", material.shininess);
|
|
}
|
|
|
|
void applyLight(const Light& light) {
|
|
setVec3("light.position", light.position);
|
|
setVec3("light.ambient", light.ambient);
|
|
setVec3("light.diffuse", light.diffuse);
|
|
setVec3("light.specular", light.specular);
|
|
}
|
|
};
|