Open Makogan opened 2 years ago
You need to list the source files which use INCBIN you want preprocessed by this tool, you don't list the data files, those are read from the INCBIN
macro in the source file which are found via -I
. So for instance you'd have:
// source.c
INCBIN(data, "phong_lighting.glsl");
Then you'd run the tool with ./incbin.exe source.c -I../../Src/Engine/EmbeddedShaders/ -o ../../buildvs/data.c
Which would emit a data.c
file containing the phong shader source code as a byte array named data
, now in source.c
you can use data
to refer to that embedded GLSL.
If you have multiple source files which use INCBIN
you'd specify them all on the command line here.
Ah I see, I was confused, thank you!
I was confused too. I think the description of how to use it should be clearer. I didn't understand that source.c
was suppossed to be the source file that contains the INCBIN macros.
Maybe you should add a little counter so it's easier to understand that nothing was found?
diff --git a/incbin.c b/incbin.c
index fd1e72b..ca6abe4 100644
--- a/incbin.c
+++ b/incbin.c
@@ -104,7 +104,7 @@ static const char *styled(int style, int ident) {
}
int main(int argc, char **argv) {
- int ret = 0, i, paths, files = 0, style = kCamel;
+ int ret = 0, i, paths, files = 0, style = kCamel, written = 0;
char outfile[FILENAME_MAX] = "data.c";
char search_paths[SEARCH_PATHS_MAX][PATH_MAX];
char prefix[FILENAME_MAX] = "g";
@@ -263,6 +263,7 @@ usage:
fprintf(out, i != size - 1 ? "0x%02X, " : "0x%02X", data[i]);
count++;
}
+ written++;
free(data);
fclose(f);
}
@@ -282,6 +283,7 @@ end:
fprintf(out, "#endif\n");
fclose(out);
printf("generated `%s'\n", outfile);
+ printf("number of files included: %d\n", written);
return 0;
}
I compiled the incbin.c file and made an executable if I run it with help I get:
If I try to run it normally (without the help flag) this is the data.c file that gets generated:
No errors or warnings are thrown by the tool.
I am on windows 10