+++ /dev/null
-// Copyright (C) 2021 Harry Godden (hgn) - All Rights Reserved
-
-#define VG_TOOLS
-#include "vg/vg.h"
-
-#define STB_IMAGE_IMPLEMENTATION
-#include "stb/stb_image.h"
-
-// Super basic model compiler
-int main( int argc, char *argv[] )
-{
- if( argc < 3 )
- {
- vg_error( "Need input/output files\n" );
- return 0;
- }
-
- FILE *output;
-
- int x,y,n;
- unsigned char *data = stbi_load( argv[1], &x, &y, &n, 4 );
-
- if( data )
- {
- output = fopen( argv[2], "w" );
- if( !output )
- {
- vg_error( "couldn't open output for writing\n" );
- free(data);
- return 0;
- }
-
- fprintf( output, "/* Font buffer generated from source file: '%s' */\n", argv[1] );
-
- u32 pixel_max = x*y;
- u32 pixel = 0, chars = 0;
- while(pixel_max)
- {
- u32 buff = 0;
- for( int b = 31; b >= 0; b-- )
- {
- buff |= data[pixel*4]>128?0x1<<b:0;
- pixel++;
-
- if( pixel >= pixel_max )
- {
- pixel_max = 0;
- break;
- }
- }
-
- fprintf( output, "%#x,", buff );
- if( (++chars) % 8 == 0 )
- fprintf( output, "\n" );
- }
-
- free(data);
- fclose(output);
-
- vg_success( "Font compiled successfully\n" );
- }
- else
- {
- vg_error( "Couldn't open source file\n" );
- return 0;
- }
-}