Put your data into variables with file2var

Use this tool to get access to your data in javascript. Example is included in github.

Embed program data within executable. Text files as c string and binary files as c array.
file2var is easy to use program to do just  that.

For example we need to collect glsl program shaders in one c file .h and .c , clanggen can be used to do exactly that.

$ ./file2var txt2str -p c -o ../src/program *.glsl

output files are program.h and program.c
--- c file
char myshader_glsl[] = "......";
--- header file
extern char *myshader_glsl;

--- in your code
#include "program.h"

int main(...) {
  glShaderSource(&shader, 1, &myshader_glsl, NULL);

Leave a Reply

Your email address will not be published. Required fields are marked *