Commit of work up to day 11 of learnopengl.com.

This commit is contained in:
Zed A. Shaw 2026-08-21 13:15:55 -04:00
commit 5ce5b4dda4
447 changed files with 126678 additions and 0 deletions

View file

@ -0,0 +1,53 @@
#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};
glm::vec3 diffuse{0.5f,0.5f,0.5f};
glm::vec3 specular{0.8f, 0.8f, 0.8f};
float shininess{32.0f};
};
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);
setVec3("material.diffuse", material.diffuse);
setVec3("material.specular", material.specular);
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);
}
};