Tying it into the framework

We have covered a lot on the subject of drawing images with SDL but we have yet to tie everything together into our framework so that it becomes reusable throughout our game. What we will now cover is creating a texture manager class that will have all of the functions we need to easily load and draw textures.

Creating the texture manager

The texture manager will have functions that allow us to load and create an SDL_Texture structure from an image file, draw the texture (either static or animated), and also hold a list of SDL_Texture*, so that we can use them whenever we need to. Let's go ahead and create the TextureManager.h file:

  1. First we declare our load function. As parameters, the function takes the filename of the ...

Get SDL Game Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.