1 // Copyright (C) 2021 Harry Godden (hgn) - All Rights Reserved
6 #define STB_IMAGE_IMPLEMENTATION
7 #include "stb/stb_image.h"
9 // Super basic model compiler
10 int main( int argc
, char *argv
[] )
14 vg_error( "Need input/output files\n" );
21 unsigned char *data
= stbi_load( argv
[1], &x
, &y
, &n
, 4 );
25 output
= fopen( argv
[2], "w" );
28 vg_error( "couldn't open output for writing\n" );
33 fprintf( output
, "/* Font buffer generated from source file: '%s' */\n", argv
[1] );
36 u32 pixel
= 0, chars
= 0;
40 for( int b
= 31; b
>= 0; b
-- )
42 buff
|= data
[pixel
*4]>128?0x1<<b
:0;
45 if( pixel
>= pixel_max
)
52 fprintf( output
, "%#x,", buff
);
53 if( (++chars
) % 8 == 0 )
54 fprintf( output
, "\n" );
60 vg_success( "Font compiled successfully\n" );
64 vg_error( "Couldn't open source file\n" );