|
@@ -4,6 +4,31 @@
|
|
#include "./simple_renderer.h"
|
|
#include "./simple_renderer.h"
|
|
#include "./gl_extra.h"
|
|
#include "./gl_extra.h"
|
|
|
|
|
|
|
|
+typedef struct {
|
|
|
|
+ Uniform_Slot slot;
|
|
|
|
+ const char *name;
|
|
|
|
+} Uniform_Def;
|
|
|
|
+
|
|
|
|
+static_assert(COUNT_UNIFORM_SLOTS == 4, "The amount of the shader uniforms have change. Please update the definition table accordingly");
|
|
|
|
+static const Uniform_Def uniform_defs[COUNT_UNIFORM_SLOTS] = {
|
|
|
|
+ [UNIFORM_SLOT_TIME] = {
|
|
|
|
+ .slot = UNIFORM_SLOT_TIME,
|
|
|
|
+ .name = "time",
|
|
|
|
+ },
|
|
|
|
+ [UNIFORM_SLOT_RESOLUTION] = {
|
|
|
|
+ .slot = UNIFORM_SLOT_RESOLUTION,
|
|
|
|
+ .name = "resolution",
|
|
|
|
+ },
|
|
|
|
+ [UNIFORM_SLOT_CAMERA_POS] = {
|
|
|
|
+ .slot = UNIFORM_SLOT_CAMERA_POS,
|
|
|
|
+ .name = "camera_pos",
|
|
|
|
+ },
|
|
|
|
+ [UNIFORM_SLOT_CAMERA_SCALE] = {
|
|
|
|
+ .slot = UNIFORM_SLOT_CAMERA_SCALE,
|
|
|
|
+ .name = "camera_scale",
|
|
|
|
+ },
|
|
|
|
+};
|
|
|
|
+
|
|
#define UNIMPLEMENTED(...) \
|
|
#define UNIMPLEMENTED(...) \
|
|
do { \
|
|
do { \
|
|
printf("%s:%d: UNIMPLEMENTED: %s \n", __FILE__, __LINE__, __VA_ARGS__); \
|
|
printf("%s:%d: UNIMPLEMENTED: %s \n", __FILE__, __LINE__, __VA_ARGS__); \
|
|
@@ -11,6 +36,13 @@
|
|
} while(0)
|
|
} while(0)
|
|
#define UNUSED(x) (void)(x)
|
|
#define UNUSED(x) (void)(x)
|
|
|
|
|
|
|
|
+static void get_uniform_location(GLuint program, GLint locations[COUNT_UNIFORM_SLOTS])
|
|
|
|
+{
|
|
|
|
+ for (Uniform_Slot slot = 0; slot < COUNT_UNIFORM_SLOTS; ++slot) {
|
|
|
|
+ locations[slot] = glGetUniformLocation(program, uniform_defs[slot].name);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
void simple_renderer_init(Simple_Renderer *sr,
|
|
void simple_renderer_init(Simple_Renderer *sr,
|
|
const char *vert_file_path,
|
|
const char *vert_file_path,
|
|
const char *color_frag_file_path,
|
|
const char *color_frag_file_path,
|