Set up struct surface, and use variable grid

This commit is contained in:
PedroEdiaz
2024-12-01 13:23:29 -06:00
parent b19100424d
commit 0729388291
3 changed files with 67 additions and 87 deletions

View File

@@ -1,5 +1,4 @@
#include "main.h"
#include "data/axis.h"
#include "data/shaders.h"
#include <stdio.h>
@@ -16,8 +15,8 @@
#define M_PI 3.14159
#endif
float *generate_data_surface(unsigned char *);
float *generate_normals_surface(float *, unsigned char);
float *generate_data_surface(unsigned char *, unsigned long *);
float *generate_normals_surface(float *, unsigned char, unsigned long);
struct projection projection = {.x = 0, .y = 1, .z = 2, .w = 3};
@@ -38,9 +37,8 @@ void mlog(char *msg)
}
window_t window;
mesh_t m_surface, m_axis;
mesh_t m_surface;
id_t shader, shader_plain;
unsigned char m;
extern volatile unsigned char animate_index;
@@ -83,14 +81,6 @@ static inline
}
clean_context();
#ifndef DEBUG
load_mdl_matrix(shader_plain, 0, 0);
draw_mesh(m_axis);
load_mdl_matrix(shader_plain, 1, 1);
draw_mesh(m_axis);
load_mdl_matrix(shader_plain, 2, 2);
draw_mesh(m_axis);
#endif
load_mdl_matrix(shader, 0, 3);
draw_mesh(m_surface);
@@ -155,32 +145,25 @@ int main(void)
mlog("[MESH] Inicializando...\n");
{
float *n_surface, *d_surface;
d_surface = generate_data_surface(&m);
n_surface = generate_normals_surface(d_surface, m);
struct surface surface;
if (!(m_surface = create_mesh(d_surface, n_surface, m)))
surface.data = generate_data_surface(&surface.dim, &surface.vertex);
surface.norm =
generate_normals_surface(surface.data, surface.dim, surface.vertex);
if (!(m_surface = create_mesh(surface)))
{
mlog("[MESH] Error al inicializar...\n");
goto error_mesh_surface;
}
projection.m = m;
projection.m = surface.dim;
projection.mesh = m_surface;
set_projection_mesh(projection);
free(n_surface);
free(d_surface);
}
mlog("[MESH] Inicializando...\n");
{
if (!(m_axis = create_mesh(d_axis, NULL, 3)))
{
mlog("[MESH] Error al inicializar...\n");
goto error_mesh_axis;
}
free(surface.norm);
free(surface.data);
}
mlog("[MAIN LOOP] Inicializando...\n");
@@ -193,8 +176,6 @@ int main(void)
#endif
mlog("[MAIN LOOP] Terminando...\n");
mlog("[MESH] Destruyendo...\n");
destroy_mesh(m_axis);
mlog("[MESH] Destruyendo...\n");
destroy_mesh(m_surface);
mlog("[SHADER] Destruyendo...\n");
@@ -207,8 +188,6 @@ int main(void)
close_window(window);
return 0;
mlog("[MESH] Destruyendo...\n");
destroy_mesh(m_axis);
error_mesh_axis:
mlog("[MESH] Destruyendo...\n");
destroy_mesh(m_surface);