Kelsidavis-WoWee/include/rendering/shader.hpp
Kelsi 4287878a73 Performance optimizations and collision improvements
Performance:
- Remove expensive inverse() from all vertex shaders (terrain, WMO, M2, water, character)
- Add uniform location caching to avoid repeated glGetUniformLocation calls
- Add proper frustum culling for WMO groups using AABB intersection
- Add distance-based culling for WMO and M2 instances
- Add cleanup of unused M2/WMO models when tiles unload

Collision & Movement:
- Add M2 doodad collision detection (fences, boxes, etc.)
- Reduce character eye height (5.0 -> 1.8) and collision radius (2.5 -> 0.5)
- Enable WoW-style movement speed by default (14 units/sec run, 5 walk, 9 back)
- Fix emote grammar ("You waves." -> "You wave.")

Misc:
- Rename window title to "Wowee"
2026-02-02 23:03:45 -08:00

46 lines
1.5 KiB
C++

#pragma once
#include <string>
#include <unordered_map>
#include <GL/glew.h>
#include <glm/glm.hpp>
namespace wowee {
namespace rendering {
class Shader {
public:
Shader() = default;
~Shader();
bool loadFromFile(const std::string& vertexPath, const std::string& fragmentPath);
bool loadFromSource(const std::string& vertexSource, const std::string& fragmentSource);
void use() const;
void unuse() const;
void setUniform(const std::string& name, int value);
void setUniform(const std::string& name, float value);
void setUniform(const std::string& name, const glm::vec2& value);
void setUniform(const std::string& name, const glm::vec3& value);
void setUniform(const std::string& name, const glm::vec4& value);
void setUniform(const std::string& name, const glm::mat3& value);
void setUniform(const std::string& name, const glm::mat4& value);
void setUniformMatrixArray(const std::string& name, const glm::mat4* matrices, int count);
GLuint getProgram() const { return program; }
private:
bool compile(const std::string& vertexSource, const std::string& fragmentSource);
GLint getUniformLocation(const std::string& name) const;
GLuint program = 0;
GLuint vertexShader = 0;
GLuint fragmentShader = 0;
// Cache uniform locations to avoid expensive glGetUniformLocation calls
mutable std::unordered_map<std::string, GLint> uniformLocationCache;
};
} // namespace rendering
} // namespace wowee