#ifndef CLASS_GRAPHIC_TRACKER #define CLASS_GRAPHIC_TRACKER #include #include #include #include #include "GraphicResource.h" #include "Image.h" #include "MovableImage.h" #include "MovableSurface.h" #include "Surface.h" #include "../Exception.h" typedef std::map ImageMap; typedef std::map MovableImageMap; namespace graphic { /// a resource tracker for Graphic objects class GraphicTracker { private: /// current graphic mode (SDL or GL) bool _graphic_mode; /// Surfaces container std::vector < Surface * > _surfaces; /// Images container ImageMap _images; //std::vector < Image * > _images; /// MovableSurfaces container std::vector < MovableSurface * > _mov_surfaces; /// MovableImages container MovableImageMap _mov_images; //std::vector < MovableImage * > _mov_images; public: /// empty constructor GraphicTracker(bool graphic_mode = SDL_GRAPHIC) { _graphic_mode = graphic_mode; }; /// destroyer ~GraphicTracker() { }; /// a new surface Surface * GetSurface(Uint16 w, Uint16 h, bool graphic_mode = SDL_GRAPHIC, Uint32 flags = SDL_SWSURFACE, bool trans = false, Uint16 bpp = screen->GetBitPP()); /// create a surface from a SDL_Surface Surface * GetSurface(SDL_Surface * surface, bool graphic_mode = SDL_GRAPHIC); /// create a new image from a file name, by default no alpha Image * GetImage(std::string file, bool graphic_mode = SDL_GRAPHIC); /// create a new image from a file name setting a color as transparent Image * GetImage(std::string file, SDL_Color trans_color, bool graphic_mode = SDL_GRAPHIC); /// create a movable surface MovableSurface * GetMovableSurface(Uint16 w, Uint16 h, bool graphic_mode = SDL_GRAPHIC, Uint32 flags = SDL_SWSURFACE, bool trans = false, Uint16 bpp = screen->GetBitPP()); /// create a new image from a file name, by default no alpha MovableImage * GetMovableImage(std::string file, bool graphic_mode = SDL_GRAPHIC); /// create a new image from a file name setting a color as transparent MovableImage * GetMovableImage(std::string file, SDL_Color trans_color, bool graphic_mode = SDL_GRAPHIC); /// delete the passed graphic resource void DeleteResource(Surface * s); /// delete all the stored graphic resources void DeleteAllResources(); #ifdef WITH_OPENGL /// change the graphic mode at runtime (SDL/GL) void ChangeGraphicMode(bool graphic_mode = SDL_GRAPHIC); /// update all the textures (this method is required by fucking win) void UpdateAllTextures(); #endif }; /// external pointer to the GraphicTracker extern GraphicTracker * gtracker; } #endif