Final: Illumination

This commit is contained in:
PedroEdiaz
2024-10-17 22:24:54 -06:00
parent 5fc19db1a9
commit 9dabea34d2
9 changed files with 65 additions and 80 deletions

View File

@@ -3,7 +3,9 @@
#include "data/axis.h"
#include "data/shaders.h"
#include <GL/glew.h>
#include <stdlib.h>
#include <cglm/vec3.h>
#define WIDTH 512
#define HEIGHT 512
@@ -27,9 +29,11 @@ void calc_normal(float* v1, float* v2, float* v3, float* normal)
glm_vec3_normalize(normal);
}
void fill_normal( float * d, float * n )
float * fill_normal( float * d )
{
//*n = *d;
float * n;
n = malloc( (*d+1)*sizeof(float));
*n = *d;
for (int i = 0; i < *d; i += 9)
{
@@ -39,12 +43,14 @@ void fill_normal( float * d, float * n )
glm_vec3_copy( norm_vec, (n+1)+i+3 );
glm_vec3_copy( norm_vec, (n+1)+i+6 );
}
return n;
}
const char * wname = "manigraph: manifold grapher";
int main( void )
{
float * n_cube, *n_axis;
id_t shader, texture;
mesh_t m_cube, m_axis;
window_t window;
@@ -57,8 +63,6 @@ int main( void )
glewInit();
fill_normal( d_cube, d_cube+(int)*d_cube);
if( !( shader = create_shader() ) )
goto error_shader;
@@ -68,12 +72,18 @@ int main( void )
load_fix_matrix( shader, (float)WIDTH/HEIGHT );
if( !( m_cube = create_mesh( d_cube ) ) )
n_cube = fill_normal( d_cube );
n_axis = fill_normal( d_axis );
if( !( m_cube = create_mesh( d_cube, n_cube ) ) )
goto error_mesh_cube;
if( !( m_axis = create_mesh( d_axis ) ) )
if( !( m_axis = create_mesh( d_axis, n_axis ) ) )
goto error_mesh_axis;
free( n_cube );
free( n_axis );
texture=create_palette_texture( palette );
use_texture( texture );