refactoring

This commit is contained in:
2025-08-17 12:40:31 -05:00
parent 47564bb3cf
commit 2a1654e80c
13 changed files with 120 additions and 1901 deletions

View File

@@ -6,7 +6,6 @@
#define MAX_ERR_MSG_LEN 256
// Visit/Variant overload pattern
// https://www.modernescpp.com/index.php/visiting-a-std-variant-with-the-overload-pattern/
template<typename ... Ts>
@@ -57,6 +56,12 @@ void set_uniform(uint id, const char* name, uniform_variant value) {
[id, name](int i) { glUniform1i(glGetUniformLocation(id, name), i); },
[id, name](float f) { glUniform1f(glGetUniformLocation(id, name), f); },
[id, name](bool b) { glUniform1i(glGetUniformLocation(id, name), b); },
[id, name](vec4 v) { glUniform4f(glGetUniformLocation(id, name), v.x, v.y, v.z, v.w); },
[id, name](vec3 v) { glUniform3f(glGetUniformLocation(id, name), v.x, v.y, v.z); },
[id, name](vec2 v) { glUniform2f(glGetUniformLocation(id, name), v.x, v.y); },
[id, name](vec4i v) { glUniform4i(glGetUniformLocation(id, name), v.x, v.y, v.z, v.w); },
[id, name](vec3i v) { glUniform3i(glGetUniformLocation(id, name), v.x, v.y, v.z); },
[id, name](vec2i v) { glUniform2i(glGetUniformLocation(id, name), v.x, v.y); },
};
visit(visitor, value);
}
@@ -64,12 +69,12 @@ void set_uniform(uint id, const char* name, uniform_variant value) {
// Privates
bool _compile_shader(uint *out_id, const char* filepath, int shader_type) {
Array<char> source;
array<char> source;
if (!read_file(&source, filepath))
return false;
uint id = glCreateShader(shader_type);
glShaderSource(id, 1, &source._data, (int*)&source.len);
glShaderSource(id, 1, &source.data, (int*)&source.len);
glCompileShader(id);
int status;
@@ -78,7 +83,7 @@ bool _compile_shader(uint *out_id, const char* filepath, int shader_type) {
char err_msg[MAX_ERR_MSG_LEN];
glGetShaderInfoLog(id, MAX_ERR_MSG_LEN, NULL, err_msg);
printf("Error compiling shader %s\n", filepath);
printf("%.*s\n", (int)source.len, source._data);
printf("%.*s\n", (int)source.len, source.data);
printf("Error msg: %s\n", err_msg);
}
*out_id = id;