Clean up codebase, rm texture, matrix -> load

This commit is contained in:
PedroEdiaz
2024-12-01 16:12:17 -06:00
parent a293008137
commit 904d686c6e
11 changed files with 169 additions and 231 deletions

View File

@@ -22,12 +22,7 @@ struct projection projection = {.x = 0, .y = 1, .z = 2, .w = 3};
const char *wname = "manigraph: manifold grapher";
unsigned char palette[][4] = {
{0xEB, 0xD3, 0xF8, 0xff},
{0xEB, 0xD4, 0xF8, 0xff},
{0xEB, 0xD5, 0xF8, 0xff},
{0x2F, 0x3C, 0x7E, 0xff},
};
unsigned char color[4] = {0x2F, 0x3C, 0x7E, 0xff};
void mlog(char *msg)
{
@@ -53,8 +48,10 @@ static inline
q = poll_input(window);
load_rot_matrix(shader, q);
load_rot_matrix(shader_plain, q);
rot_matrix_load(shader, q);
rot_matrix_load(shader_plain, q);
color_load(shader, color);
color_load(shader_plain, color);
{
static float angle = 0;
@@ -71,8 +68,8 @@ static inline
if (animate_index)
{
load_uint_to_shader(shader, "i", animate_index - 1);
load_uint_to_shader(shader_plain, "i", animate_index - 1);
load_float_to_shader(shader, "i", animate_index - 1);
load_float_to_shader(shader_plain, "i", animate_index - 1);
angle += 0.01;
load_float_to_shader(shader, "angle", angle);
@@ -81,16 +78,12 @@ static inline
}
clean_context();
load_mdl_matrix(shader, 0, 3);
draw_mesh(m_surface);
load_mdl_matrix(shader_plain, 0, 3);
draw_mesh_lines(m_surface);
draw_mesh(shader, m_surface);
draw_mesh_lines(shader_plain, m_surface);
}
int main(void)
{
id_t texture;
mlog("[VENTANA] Inicializando...\n");
{
@@ -113,12 +106,6 @@ int main(void)
set_clean_color_context(0xFF, 0xFF, 0xFF);
}
mlog("[TEXTURE] Inicializando...\n");
{
texture = create_palette_texture(palette, 4);
use_texture(texture);
}
mlog("[SHADER] Inicializando...\n");
{
if (!(shader = create_shader()))
@@ -128,7 +115,7 @@ int main(void)
}
load_program_to_shader(shader, vs, VERTEX);
load_program_to_shader(shader, fs, FRAGMENT);
load_fix_matrix(shader, (float)WIDTH / HEIGHT);
fix_matrix_load(shader, (float)WIDTH / HEIGHT);
}
mlog("[SHADER] Inicializando...\n");
@@ -140,7 +127,7 @@ int main(void)
}
load_program_to_shader(shader_plain, vs, VERTEX);
load_program_to_shader(shader_plain, fs_plain, FRAGMENT);
load_fix_matrix(shader_plain, (float)WIDTH / HEIGHT);
fix_matrix_load(shader_plain, (float)WIDTH / HEIGHT);
}
mlog("[MESH] Inicializando...\n");
@@ -182,13 +169,11 @@ int main(void)
destroy_shader(shader_plain);
mlog("[SHADER] Destruyendo...\n");
destroy_shader(shader);
mlog("[TEXTURE] Destruyendo...\n");
destroy_texture(texture);
mlog("[WINDOW] Destruyendo...\n");
close_window(window);
return 0;
error_mesh_axis:
error_context:
mlog("[MESH] Destruyendo...\n");
destroy_mesh(m_surface);
error_mesh_surface:
@@ -198,9 +183,6 @@ error_shader_plain:
mlog("[SHADER] Destruyendo...\n");
destroy_shader(shader);
error_shader:
mlog("[TEXTURE] Destruyendo...\n");
destroy_texture(texture);
error_context:
mlog("[WINDOW] Destruyendo...\n");
close_window(window);
error_window: