58 lines
1.1 KiB
C++
58 lines
1.1 KiB
C++
#ifndef DEF_XMANAGER_H
|
|
|
|
#define DEF_XMANAGER_H
|
|
class xManager{
|
|
|
|
public:
|
|
xManager(const char *t, int w, int h);
|
|
~xManager();
|
|
SDL_Window *window();
|
|
SDL_Renderer *renderer();
|
|
bool status();
|
|
bool setBackground(Uint8 r=0xff, Uint8 g=0xff, Uint8 b=0xff, Uint8 a=0xff);
|
|
bool setImage(const char *url);
|
|
|
|
void push(SDL_Texture *t, SDL_Rect *origin, SDL_Rect *dest);
|
|
void pull(SDL_Texture *t);
|
|
|
|
void update();
|
|
|
|
void manageFps(const int fps=0);
|
|
|
|
|
|
// Gestion des evenements
|
|
void attachEvent(SDL_EventType t, void(*handler)(SDL_Event*) );
|
|
void manageEvents(SDL_Event* event);
|
|
|
|
|
|
private:
|
|
// gestion FPS
|
|
Uint32 _lasttick;
|
|
Uint32 _fpstime;
|
|
|
|
// Gestion evenements
|
|
vector<SDL_EventType> _events;
|
|
vector<void(*)(SDL_Event*)> _handlers;
|
|
|
|
// status de l'initialisation
|
|
bool _status;
|
|
|
|
// Elements utiles
|
|
SDL_Window *_window;
|
|
SDL_Rect _winrect;
|
|
|
|
SDL_Renderer *_renderer;
|
|
SDL_Texture *_texture;
|
|
|
|
// Gestion des textures
|
|
vector<SDL_Texture*> _sprites;
|
|
vector<SDL_Rect*> _src;
|
|
vector<SDL_Rect*> _dst;
|
|
|
|
// Protection thread-safe
|
|
mutex _mutex;
|
|
|
|
|
|
};
|
|
|
|
#endif |