Allow droping klein files

This commit is contained in:
PedroEdiaz
2024-12-01 21:33:27 -06:00
parent 733ababde0
commit fd598255f4
3 changed files with 36 additions and 42 deletions

View File

@@ -15,7 +15,7 @@
#define M_PI 3.14159
#endif
struct projection projection = {.x = 0, .y = 1, .z = 2, .w = 3};
struct projection projection = {.x = 0, .y = 1, .z = 2, .w = 3, .mesh = NULL};
const char *wname = "manigraph: manifold grapher";
@@ -29,7 +29,6 @@ void mlog(char *msg)
}
window_t window;
mesh_t m_surface;
id_t shader, shader_plain;
extern volatile unsigned char animate_index;
@@ -75,8 +74,11 @@ static inline
}
clean_context();
draw_mesh(shader, m_surface);
draw_mesh_lines(shader_plain, m_surface);
if (!projection.mesh)
return;
draw_mesh(shader, projection.mesh);
draw_mesh_lines(shader_plain, projection.mesh);
}
int main(void)
@@ -127,30 +129,6 @@ int main(void)
fix_matrix_load(shader_plain, (float)WIDTH / HEIGHT);
}
mlog("[MESH] Inicializando...\n");
{
struct surface surface;
if( create_surface_klein("test.klein", &surface) )
{
mlog("[MESH] Error al leer el archivo...\n");
goto error_mesh_surface;
}
if (!(m_surface = create_mesh(surface)))
{
mlog("[MESH] Error al inicializar...\n");
goto error_mesh_surface;
}
projection.m = surface.dim;
projection.mesh = m_surface;
set_projection_mesh(projection);
free(surface.norm);
free(surface.data);
}
mlog("[MAIN LOOP] Inicializando...\n");
#ifdef EMSCRIPTEN
emscripten_set_main_loop(&main_loop, 60, 1);
@@ -162,7 +140,7 @@ int main(void)
mlog("[MAIN LOOP] Terminando...\n");
mlog("[MESH] Destruyendo...\n");
destroy_mesh(m_surface);
destroy_mesh(projection.mesh);
mlog("[SHADER] Destruyendo...\n");
destroy_shader(shader_plain);
mlog("[SHADER] Destruyendo...\n");
@@ -172,9 +150,6 @@ int main(void)
return 0;
error_context:
mlog("[MESH] Destruyendo...\n");
destroy_mesh(m_surface);
error_mesh_surface:
mlog("[SHADER] Destruyendo...\n");
destroy_shader(shader_plain);
error_shader_plain: