Add .clang-format and .gitignore
This commit is contained in:
90
src/main.c
Executable file → Normal file
90
src/main.c
Executable file → Normal file
@@ -2,41 +2,51 @@
|
||||
#include "data/axis.h"
|
||||
#include "data/shaders.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define WIDTH 512
|
||||
#define HEIGHT 512
|
||||
|
||||
float * generate_data_surface(unsigned int, unsigned char *);
|
||||
float * generate_normals_surface(float *, unsigned char);
|
||||
float *generate_data_surface(unsigned int, unsigned char *);
|
||||
float *generate_normals_surface(float *, unsigned char);
|
||||
|
||||
unsigned char palette[] =
|
||||
{
|
||||
0xEB,0xD3,0xF8,0xff,
|
||||
0xEB,0xD4,0xF8,0xff,
|
||||
0xEB,0xD5,0xF8,0xff,
|
||||
0x7A,0x1C,0xAC,0xff,
|
||||
unsigned char palette[] = {
|
||||
0xEB,
|
||||
0xD3,
|
||||
0xF8,
|
||||
0xff,
|
||||
0xEB,
|
||||
0xD4,
|
||||
0xF8,
|
||||
0xff,
|
||||
0xEB,
|
||||
0xD5,
|
||||
0xF8,
|
||||
0xff,
|
||||
0x7A,
|
||||
0x1C,
|
||||
0xAC,
|
||||
0xff,
|
||||
};
|
||||
|
||||
const char * wname = "manigraph: manifold grapher";
|
||||
const char *wname = "manigraph: manifold grapher";
|
||||
|
||||
struct projection projection =
|
||||
{
|
||||
.x=0,
|
||||
.y=1,
|
||||
.z=2,
|
||||
.w=3,
|
||||
struct projection projection = {
|
||||
.x = 0,
|
||||
.y = 1,
|
||||
.z = 2,
|
||||
.w = 3,
|
||||
};
|
||||
|
||||
void mlog( char * msg )
|
||||
void mlog(char *msg)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf(msg);
|
||||
#endif
|
||||
}
|
||||
|
||||
int main( void )
|
||||
int main(void)
|
||||
{
|
||||
id_t shader, texture, shader_plain;
|
||||
mesh_t m_surface, m_axis;
|
||||
@@ -44,7 +54,7 @@ int main( void )
|
||||
|
||||
mlog("[VENTANA] Inicializando...\n");
|
||||
{
|
||||
if(!(window = init_window(WIDTH, HEIGHT, wname)))
|
||||
if (!(window = init_window(WIDTH, HEIGHT, wname)))
|
||||
{
|
||||
mlog("[VENTANA] Error al inicializar...\n");
|
||||
goto error_window;
|
||||
@@ -56,88 +66,87 @@ int main( void )
|
||||
|
||||
mlog("[CONTEXT] Inicializando...\n");
|
||||
{
|
||||
if(!(init_context()))
|
||||
if (!(init_context()))
|
||||
{
|
||||
mlog("[CONTEXT] Error al inicializar...\n");
|
||||
goto error_context;
|
||||
goto error_context;
|
||||
}
|
||||
}
|
||||
|
||||
mlog("[TEXTURE] Inicializando...\n");
|
||||
{
|
||||
texture=create_palette_texture(palette, 4);
|
||||
texture = create_palette_texture(palette, 4);
|
||||
use_texture(texture);
|
||||
}
|
||||
|
||||
mlog("[SHADER] Inicializando...\n");
|
||||
{
|
||||
if(!(shader = create_shader()))
|
||||
{
|
||||
if (!(shader = create_shader()))
|
||||
{
|
||||
mlog("[SHADER] Error al inicializar...\n");
|
||||
goto error_shader;
|
||||
}
|
||||
load_program_to_shader(shader, vs, VERTEX);
|
||||
load_program_to_shader(shader, fs, FRAGMENT);
|
||||
load_fix_matrix(shader, (float)WIDTH/HEIGHT);
|
||||
load_fix_matrix(shader, (float)WIDTH / HEIGHT);
|
||||
}
|
||||
|
||||
mlog("[SHADER] Inicializando...\n");
|
||||
{
|
||||
if(!(shader_plain = create_shader()))
|
||||
if (!(shader_plain = create_shader()))
|
||||
{
|
||||
mlog("[SHADER] Error al inicializar...\n");
|
||||
goto error_shader_plain;
|
||||
}
|
||||
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);
|
||||
load_fix_matrix(shader_plain, (float)WIDTH / HEIGHT);
|
||||
}
|
||||
|
||||
mlog("[MESH] Inicializando...\n");
|
||||
{
|
||||
unsigned char m;
|
||||
float * n_surface, *d_surface;
|
||||
d_surface = generate_data_surface(16,&m);
|
||||
float *n_surface, *d_surface;
|
||||
d_surface = generate_data_surface(16, &m);
|
||||
n_surface = generate_normals_surface(d_surface, m);
|
||||
|
||||
projection.m=m;
|
||||
projection.m = m;
|
||||
|
||||
if( !(m_surface = create_mesh(d_surface, n_surface, m)))
|
||||
if (!(m_surface = create_mesh(d_surface, n_surface, m)))
|
||||
{
|
||||
mlog("[MESH] Error al inicializar...\n");
|
||||
goto error_mesh_surface;
|
||||
goto error_mesh_surface;
|
||||
}
|
||||
|
||||
projection.mesh=m_surface;
|
||||
projection.mesh = m_surface;
|
||||
|
||||
free(n_surface);
|
||||
free(d_surface);
|
||||
|
||||
}
|
||||
|
||||
mlog("[MESH] Inicializando...\n");
|
||||
{
|
||||
if(!(m_axis = create_mesh(d_axis, NULL, 3)))
|
||||
if (!(m_axis = create_mesh(d_axis, NULL, 3)))
|
||||
{
|
||||
mlog("[MESH] Error al inicializar...\n");
|
||||
goto error_mesh_axis;
|
||||
goto error_mesh_axis;
|
||||
}
|
||||
}
|
||||
|
||||
mlog("[MAIN LOOP] Inicializando...\n");
|
||||
while(is_open_window(window))
|
||||
while (is_open_window(window))
|
||||
{
|
||||
quat_t q;
|
||||
|
||||
q=poll_input(window);
|
||||
q = poll_input(window);
|
||||
load_rot_matrix(shader, q);
|
||||
load_rot_matrix(shader_plain, q);
|
||||
|
||||
|
||||
clean_context();
|
||||
|
||||
#ifndef DEBUG
|
||||
load_mdl_matrix(shader_plain, 0, 0);
|
||||
draw_mesh( m_axis);
|
||||
draw_mesh(m_axis);
|
||||
load_mdl_matrix(shader_plain, 1, 1);
|
||||
draw_mesh(m_axis);
|
||||
load_mdl_matrix(shader_plain, 2, 2);
|
||||
@@ -164,7 +173,6 @@ int main( void )
|
||||
close_window(window);
|
||||
return 0;
|
||||
|
||||
|
||||
mlog("[MESH] Destruyendo...\n");
|
||||
destroy_mesh(m_axis);
|
||||
error_mesh_axis:
|
||||
|
||||
Reference in New Issue
Block a user