refactoring
This commit is contained in:
3
inc/globj.hpp
Normal file
3
inc/globj.hpp
Normal file
@@ -0,0 +1,3 @@
|
||||
#include "util.hpp"
|
||||
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
namespace shader {
|
||||
|
||||
// Reads shader source files, compiles, and links
|
||||
bool load(uint* out_id, const char *vertex_filepath, const char *fragment_filepath);
|
||||
bool load(uint* out_id, const char* vertex_filepath, const char* fragment_filepath);
|
||||
|
||||
// Sets shader as active on the gpu
|
||||
void use(uint id);
|
||||
|
||||
// Set uniform value
|
||||
typedef std::variant<int, float, bool> uniform_variant;
|
||||
void set_uniform(uint id, const char *name, uniform_variant value);
|
||||
typedef std::variant<int, float, bool, vec4, vec3, vec2, vec4i, vec3i, vec2i> uniform_variant;
|
||||
void set_uniform(uint id, const char* name, uniform_variant value);
|
||||
|
||||
} // namespace shaders
|
||||
|
||||
43
inc/util.hpp
43
inc/util.hpp
@@ -2,13 +2,48 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
template<class T> struct Array {
|
||||
T* _data;
|
||||
template<class T> struct array {
|
||||
T* data;
|
||||
size_t len;
|
||||
|
||||
T& operator[](int i);
|
||||
};
|
||||
|
||||
typedef unsigned int uint;
|
||||
|
||||
bool read_file(Array<char>* out, const char* filepath);
|
||||
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