Hello everybody,
I'd like to know if anyone here has used an archive for your game images. Something like the PhysicsFS library.
The thing is, my game will have some images that I don't want to simply let them in a data directory so anyone could see them. It would be some kind of a spoiler.
iarwain,
how difficult would it be to implement something like that in orx?
Thanks.
Comments
Then I got distracted with something else, like unicode support or font generation, can't remember.
In your case though, you can load the texture yourself with PhysicsFS to memory and then create the texture manually (look at how it's done for the default font texture in orxFont.c for example). It's not too bad.
Another (easier) option that wouldn't involve any external library would be to apply a xor filter, for example, to all your textures for example and reprocess them when they're loaded in orx, this way the versions on file will just look like garbage. In this case you let orx load all his stuff by himself, then when you get the orxOBJECT_EVENT_CREATE event, you look at its content, if it's a texture you haven't processed yet, then do it now. I can help with that process by adding events for texture creation/deletion which would allow you to process them without any other consideration to take.
I think your xor filter suggestion is good enough. So if you can add those events for texture creation/deletion, that would be great.
So, after a texture creation event is triggered, how can I access the texture data?
Just ignore the first few create event as they'll be for internal textures used by orx (screen, pixel, default font), but you can easily filter them out using their name (probably empty).
So here it is:
I tried applying the filter, but I'm having a little trouble and I think it is because I'm trying to apply the filter in a png image. As png images are compressed, I think I can't just load the texture, apply the filter and save it. Am I right?
Or you can use orx to load the texture, modify them and save them back.
This is very easy and require not much code but you can't save the texture back to .png as orx only supports writing tga, bmp or dds files. You then have to batch convert your images back to png using something like image magick or xnview. Not very handy I admit, I should look into supporting saving png files (but libpng is a bit of a mess).
Thanks.