Currently I use bmp files for an SDL app, but I want to hide them to distribute my exe. I thought moving them as raw bytes into header files was a good way, since the BMP are very simple Black&White patterns.
Am not sure if this is possible by using SDL only, but so far I fail to load a simple pattern of bits.
// data.h
const unsigned char rawPixels[] =
{
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,0xFF, 0xFF, 0xFF, 0xFF,0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,0xFF, 0xFF, 0xFF, 0xFF,0xFF, 0xFF, 0xFF, 0xFF,
};
// main.cpp
...
SDL_RWops *pixelsWop = SDL_RWFromConstMem((const unsigned char *)rawPixels, sizeof(rawPixels));
SDL_Surface *pixelsSurface = SDL_LoadBMP_RW(pixelsWop, 1);
SDL_BlitSurface(pixelsSurface, NULL, NULL, NULL);
...
I only get an empty surface from the SDL_LoadBMP_RW call, maybe the array should contain proper BMP header, etc. Could someone point out if that's the problem? Is there another way of loading this?