I have a sprite class which uses an SDL_Texture
over an SDL_Surface
in lieu of perfomance. The class looks something like this:
class Sprite
{
public:
...
private:
SDL_Texture *m_texture;
SDL_Rect m_blitRect;
int m_x;
int m_y;
};
Now the problem is when creating an SDL_Texture
you also need an SDL_Renderer
object as well as an SDL_Surface
to create it. Normally this would look something like this:
SDL_Texture *texture = SDL_CreateTextureFromSurface(renderer, surface);
The SDL surface can be created and disposed of while creating the texture however, the problem is, I want to be able to have a rendering object that isn't global. I want a decoupled framework and I don't know how to achieve that in this instance. My first thought was to make a renderer class and have it as a constructor argument but that cannot happen as it would complicate things down the road and cannot be an option. Are there any other ways to decouple the two?