In the past i wrote a few Application with working Data that were added as BLOB into the Data Segment of the Binary. But this i made in plain C.
Example, adding a texture to executable with C:
The C-Way:
1. Creating Object from Texture
ld -r -b binary texture.png -o texture.o
2. Adding Object
gcc $(FLAGS) main.c -o app.exe $(INCLUDE_DIR) $(LIB_DIR) $(LIBS) texture.o
3. Using in Sources
Declaration:
extern unsigned char _binary_texture_png_start;
extern unsigned char _binary_texture_png_size;
Reading:
SDL_RWops *tex_mem = SDL_RWFromMem(&_binary_texture_png_start,(intptr_t)&_binary_texture_png_size);
if (tex_mem == NULL) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Load image from memory fail : %s\n",SDL_GetError());
return false;
}
Questions:
How can i implement this in plain Rust? Currently i would add this in C as well and calling the Rust lib with this Data, but this sounds a little bit complicated. What do you mean? Maybe you can give me some advices or hints to find a pure Rust Solution?
Maybe I also missed a helpful post in the forum?