Read klein files, xd
This commit is contained in:
30
src/klein.c
Normal file
30
src/klein.c
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
#include "main.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int create_surface_klein( unsigned char * path, struct surface * surface )
|
||||||
|
{
|
||||||
|
unsigned long size;
|
||||||
|
char buffer[5];
|
||||||
|
FILE * file = fopen(path, "rb" );
|
||||||
|
if( !file )
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
fread(buffer, 1, 5, file );
|
||||||
|
|
||||||
|
if( strncmp(buffer, "KLEIN", 5 ) )
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
fread(buffer, 1, 1, file );
|
||||||
|
fread(&surface->dim, 1, 1, file);
|
||||||
|
fread(&surface->vertex, 8, 1, file);
|
||||||
|
|
||||||
|
size = surface->dim * surface->vertex;
|
||||||
|
|
||||||
|
surface->data=malloc(16*size );
|
||||||
|
fread(surface->data, 16,size, file);
|
||||||
|
|
||||||
|
surface->norm=malloc(16*size );
|
||||||
|
fread(surface->norm, 16, size, file);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user