loadTexture(), which takes a string and a pointer to an SDL_Renderer.getTexture(), which returns a pointer to the texture.operator, which takes a string and returns an SDL_Rect pointer.With a little foresight, we’re also going to declare three methods in addition to the constructor and destructor, they are: Next step is to include SDL in your source file, like so: #include Īnd then write your main() and initialize SDL: if ( SDL_Init ( SDL_INIT_VIDEO )) (for reading the file) and json/json.h (for parsing the json, duh!). If you’re using Visual Studio like me, you’ll need to open up your project properties, go to VC++ Directories and add the path to your sdl includes and libraries in the appropriate files (detailed info on that here). It spits out xml files but there are plenty of online converters).įirst off, you’ll want to write your main.cpp and set up SDL in your application. A json file that points to the packed texture and defines the subtextures (I’m using Shoebox to pack the textures, which depends on Adobe Air.Jsoncpp (to generate the source files, just run amalgamate.py from the repo, the files can then be found in the dist folder).The SDL Image library ( Direct download).SDL (if you don’t know SDL, but want to, there are plenty of helpful tutorials here).Though this is a reasonably simple procedure, there are some prerequisites: In this tutorial I will walk you through animating a sprite with a texture packer.