working rotation and zoom. pan bad
This commit is contained in:
19
inc/body.hpp
Normal file
19
inc/body.hpp
Normal 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);
|
||||
@@ -1,3 +0,0 @@
|
||||
#include "util.hpp"
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
38
inc/util.hpp
38
inc/util.hpp
@@ -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;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user