working rotation and zoom. pan bad

This commit is contained in:
2025-08-18 13:41:15 -05:00
parent 2a1654e80c
commit a00bac0b3f
15 changed files with 320 additions and 204 deletions

19
inc/body.hpp Normal file
View File

@@ -0,0 +1,19 @@
#pragma once
#include <glm/ext/matrix_float4x4.hpp>
#include <glm/glm.hpp>
#include "util.hpp"
struct body {
glm::mat4 pose;
uint ebo;
uint vao;
uint vbo;
uint shader;
array<float> verts;
array<int> faces;
glm::vec4 color;
};
bool load_body(body* out_body, const char* obj_filepath);
void draw_body(const body& b);

View File

@@ -1,3 +0,0 @@
#include "util.hpp"

View File

@@ -2,18 +2,16 @@
#include <glad/glad.h>
#include <variant>
#include <glm/glm.hpp>
#include "util.hpp"
namespace shader {
// Reads shader source files, compiles, and links
bool load(uint* out_id, const char* vertex_filepath, const char* fragment_filepath);
bool load_shader(uint* out_id, const char* vertex_filepath, const char* fragment_filepath);
// Sets shader as active on the gpu
void use(uint id);
void use_shader(uint id);
// Set uniform value
typedef std::variant<int, float, bool, vec4, vec3, vec2, vec4i, vec3i, vec2i> uniform_variant;
typedef std::variant<int, float, bool, glm::vec4, glm::vec3, glm::vec2, glm::ivec4, glm::ivec3, glm::ivec2, glm::mat4>
uniform_variant;
void set_uniform(uint id, const char* name, uniform_variant value);
} // namespace shaders

View File

@@ -5,45 +5,9 @@
template<class T> struct array {
T* data;
size_t len;
T& operator[](int i);
inline T& operator[](int i) { return data[i]; }
};
typedef unsigned int uint;
bool read_file(array<char>* out, const char* filepath);
struct vec4 {
float x;
float y;
float z;
float w;
};
struct vec3 {
float x;
float y;
float z;
};
struct vec2 {
float x;
float y;
};
struct vec4i {
int x;
int y;
int z;
int w;
};
struct vec3i {
int x;
int y;
int z;
};
struct vec2i {
int x;
int y;
};