c++ - How to decouple SDL_Texture from SDL_Renderer? -
c++ - How to decouple SDL_Texture from SDL_Renderer? -
i have sprite class uses sdl_texture
on sdl_surface
in lieu of perfomance. class looks this:
class sprite { public: ... private: sdl_texture *m_texture; sdl_rect m_blitrect; int m_x; int m_y; };
now problem when creating sdl_texture
need sdl_renderer
object sdl_surface
create it. this:
sdl_texture *texture = sdl_createtexturefromsurface(renderer, surface);
the sdl surface can created , disposed of while creating texture however, problem is, want able have rendering object isn't global. want decoupled framework , don't know how accomplish in instance. first thought create renderer class , have constructor argument cannot happen complicate things downwards road , cannot option. there other ways decouple two?
if want decouple texture
renderer
, surface
parameter, think best best delay phone call sdl_createtexturefromsurface
until these arguments.
that way, texture
texture constructor not use/need these arguments.
c++ sdl sdl-2 decoupling
Comments
Post a Comment