revised model loading order
[csRadar.git] / csr32f.h
1 // Implementation of: Portable float-map
2 // Spec: https://web.archive.org/web/20100708234919/gl.ict.usc.edu/HDRShop/PFM/PFM_Image_File_Format.html
3 // Known to work in: Substance Designer ( Use node format c32f )
4
5 // Write pfm file to disk (32 bpc, RGB floats) (96 bits per pixel)
6 int csr_32f_write( char const *path, int w, int h, float const *buffer )
7 {
8 FILE *write_ptr;
9 uint32_t image_size_bytes;
10
11 write_ptr = fopen( path, "wb" );
12
13 if( !write_ptr )
14 return 0;
15
16 // Write header (little endian)
17 fprintf( write_ptr, "PF\n%d %d\n-1.0\n", w, h );
18
19 image_size_bytes = w * h * sizeof( float ) * 3;
20
21 // Write data
22 fwrite( buffer, image_size_bytes, 1, write_ptr );
23
24 fclose( write_ptr );
25
26 return 1;
27 }