refactor(src/klein.c): Fix values on klein format

This commit is contained in:
PedroEdiaz
2025-04-12 11:38:55 -06:00
parent 533109fbcd
commit d2d6794f08
3 changed files with 11 additions and 9 deletions

View File

@@ -39,8 +39,8 @@ int klein_export_file(struct klein klein, const char * filename)
fwrite("\0", 1, 1, file); fwrite("\0", 1, 1, file);
fwrite(&klein.dim, 1, 1, file); fwrite(&klein.dim, 1, 1, file);
fwrite(&klein.vertex_size, 8, 1, file); fwrite(&klein.vertex_size, 8, 1, file);
fwrite(klein.vertex, 16, klein.vertex_size * klein.dim, file); fwrite(klein.vertex, 4, klein.vertex_size * klein.dim, file);
fwrite(klein.normals, 16, klein.vertex_size * klein.dim, file); fwrite(klein.normals, 4, klein.vertex_size * klein.dim, file);
fclose(file); fclose(file);
return 0; return 0;

View File

@@ -7,7 +7,7 @@
5 bytes with KLEIN 5 bytes with KLEIN
1 byte empty for scaling 1 byte empty for scaling
1 byte with the dimention of the surface 1 byte with the dimention of the surface
8 bytes interprated as a long with the number of vertex 8 bytes interprated as an int with the number of vertex
n bytes with the vertex data of the surface n bytes with the vertex data of the surface
n bytes with the normal data of the surface n bytes with the normal data of the surface
@@ -35,10 +35,10 @@ int create_surface_klein(unsigned char *path, struct surface *surface)
size = surface->dim * surface->vertex; size = surface->dim * surface->vertex;
surface->data = malloc(16 * size); surface->data = malloc(4 * size);
fread(surface->data, 16, size, file); fread(surface->data, 4, size, file);
surface->norm = malloc(16 * size); surface->norm = malloc(4 * size);
fread(surface->norm, 16, size, file); fread(surface->norm, 4, size, file);
return 0; return 0;
} }

View File

@@ -4,7 +4,9 @@
error of the shaders. error of the shaders.
*/ */
#include <stdint.h>
#define DEBUG #define DEBUG
#define GLFW_INCLUDE_NONE
typedef const void *window_t; typedef const void *window_t;
typedef unsigned int id_t; typedef unsigned int id_t;
@@ -40,8 +42,8 @@ struct projection
struct surface struct surface
{ {
float *data, *norm; float *data, *norm;
unsigned long vertex; uint64_t vertex;
unsigned char dim; uint8_t dim;
}; };
/* /*