Fix: cube, add test for cube generation

This commit is contained in:
PedroEdiaz
2024-12-01 00:13:26 -06:00
parent 468f9f951d
commit 1a0b804b57
2 changed files with 101 additions and 84 deletions

View File

@@ -16,10 +16,10 @@
#define M_PI 3.14159
#endif
float *generate_data_surface(unsigned int, unsigned char *);
float *generate_data_surface(unsigned char *);
float *generate_normals_surface(float *, unsigned char);
struct projection projection = {.x = 3, .y=1, .z=2, .w=0 };
struct projection projection = {.x = 0, .y = 1, .z = 2, .w = 3};
const char *wname = "manigraph: manifold grapher";
@@ -40,13 +40,15 @@ void mlog(char *msg)
window_t window;
mesh_t m_surface, m_axis;
id_t shader, shader_plain;
unsigned char m;
extern volatile unsigned char animate_index;
#ifndef EMSCRIPTEN
static inline
#endif
void main_loop(void)
void
main_loop(void)
{
quat_t q;
@@ -58,25 +60,23 @@ void main_loop(void)
{
static float angle = 0;
if( animate_index )
if (animate_index && m)
{
angle+=0.01;
angle += 0.01;
load_uint_to_shader( shader, "i", animate_index-1 );
load_uint_to_shader( shader_plain, "i", animate_index-1 );
load_float_to_shader( shader, "angle", angle);
load_float_to_shader( shader_plain, "angle", angle);
load_uint_to_shader(shader, "i", animate_index - 1);
load_uint_to_shader(shader_plain, "i", animate_index - 1);
load_float_to_shader(shader, "angle", angle);
load_float_to_shader(shader_plain, "angle", angle);
}
if( angle > M_PI/2 && angle )
if (angle > M_PI / 2 && angle)
{
animate_index=0;
animate_index = 0;
angle = 0;
}
}
clean_context();
#ifndef DEBUG
@@ -88,11 +88,10 @@ void main_loop(void)
draw_mesh(m_axis, 1);
#endif
load_mdl_matrix(shader, 0, 3);
draw_mesh(m_surface,0);
draw_mesh(m_surface, 0);
load_mdl_matrix(shader_plain, 0, 3);
draw_mesh(m_surface,1);
draw_mesh(m_surface, 1);
}
int main(void)
@@ -152,9 +151,8 @@ int main(void)
mlog("[MESH] Inicializando...\n");
{
unsigned char m;
float *n_surface, *d_surface;
d_surface = generate_data_surface(16, &m);
d_surface = generate_data_surface(&m);
n_surface = generate_normals_surface(d_surface, m);
if (!(m_surface = create_mesh(d_surface, n_surface, m)))
@@ -166,8 +164,7 @@ int main(void)
projection.m = m;
projection.mesh = m_surface;
set_projection_mesh( projection );
set_projection_mesh(projection);
free(n_surface);
free(d_surface);