Tuesday, April 8, 2014

SDL_Vault complete!!-ish

Hello Again,

After a lot of time finding excuses not to work on my main projects, this one got to a point where I can no longer waste time on it. I can't think of anything I'd want to add to it as of now, and now I have no other option but to go back to the code SpaceRock Miners... That probably means it is complete! Well, kind of amateurish, but that's exactly what I am, don't judge me. I am simply adding the files to my projects and they are compiled alongside with my code. It is still missing a decent build mechanism, but this has been postponed indefinitely.

And linux heard: you shall not link this dynamically!

Download

Clone it from GitHub.

Download the PDF Documentation  (two classes, small stuff).


What about it?

For a comprehensive list of goodies:

  • MIT License (Yes!).
  • Allows you to load SDL_Texture, Mix_Music and Mix_Chunk from files
  • Users can push manually hand-loaded assets into the vault and let it care about freeing it later.
  • Configurable expiration time, so it will wait until an asset is unused for too long before freeing it; this is to prevent unnecessary freeing and reloading of assets.
  • Automatic asset loading. If you call a Get function, it automatically load it if it is not already cached.
  • Manual or Timed Automatic freeing of unused assets. You call FreeUnused() function manually or set up a periodic, automatic, cleanup.
  • Strong and Weak references. You can ask for a shared_ptr or for a classic pointer, just make sure you know what you're doing when using plain pointers.
  • No Singletons.
  • Doxygen!
  • Depends on C++11, remember to set the standard for it (-std=c++11) .
Its problems would be:
  • No SDL initialization. You should to initialize SDL yourself; at least Video, Audio and Timer.
  • std::shared_ptr based. It kind of forces you to use shared_ptr (you can still code a wrapper though).
 So, hope you guys like this, and use it, as I certainly will.
Over and Out.