Comment by cowtools
3 years ago
Interesting. I look forward to this. What I've been doing now to embed a source.png file is something like this, where I generate source code from a file's data:
in embed_dump.cpp:
#include <fstream>
#include <iostream>
int main(){
std::ifstream f;
f.open("./source.png");
std::cout
<< "//automatically generated by embed_dump from project files:" << std::endl
<< "const char embedded_tex[] = {";
char a;
while(f.good()){
f.read(&a,1);
std::cout << int(a) << ",";
}
std::cout << "};" << std::endl;
f.close();
}
Then I set up my makefile like this (main_stuff.cpp #includes embedded_files.h):
main_stuff: main_stuff.cpp embedded_files.h
c++ main_stuff.cpp
embeded_files.h: embed_dump source.png
./embed_dump > embeded_files.h
embed_dump: embed_dump.cpp
c++ embed_dump.cpp -o embed_dump
No comments yet
Contribute on Hacker News ↗