00001 #ifndef VIDEO_H
00002 #define VIDEO_H
00003
00004 #include <stdint.h>
00005 #include <string>
00006 #include <list>
00007 #include <SDL/SDL.h>
00008
00009 struct SDL_Surface;
00010 namespace annie {
00011
00016 class Video {
00017 public:
00019 static Video &getInstance();
00020
00022 static void deinit();
00023
00029 void setWindow(unsigned x, unsigned y, bool redrawThread=false, bool openGL=false);
00030 unsigned getWindowWidth() const;
00031 unsigned getWindowHeight() const;
00032
00034 class Redrawer {
00035 public:
00037 Redrawer() { setFullViewport(); }
00038 virtual ~Redrawer() {}
00039 Redrawer(uint ox, uint oy, uint sx, uint sy) { offsetX = ox; offsetY = oy; sizeX = sx; sizeY = sy; }
00040 void doRedraw();
00041
00045 void setViewport(uint ox, uint oy, uint sx, uint sy) { offsetX = ox; offsetY = oy; sizeX = sx; sizeY = sy; }
00046
00048 void setFullViewport();
00049 protected:
00050
00056 virtual void draw()=0;
00057
00058 private:
00060 uint offsetX, offsetY, sizeX, sizeY;
00061 };
00062
00063
00064
00069 void addRedraw(Redrawer *r);
00070
00072 void removeRedraw(Redrawer *r);
00073
00075 void redraw();
00076
00077 void waitForKey();
00078
00079 bool gl() { return usesGL; }
00080
00081
00082 void flip();
00083 protected:
00084 typedef std::list<Redrawer *> Painters;
00085 Painters painters;
00086 SDL_Surface *screen;
00087
00088 Video();
00089 ~Video();
00090 private:
00091 bool redrawThread;
00092 bool usesGL;
00093 };
00094
00096 extern SDL_PixelFormat defaultRGBformat;
00097 }
00098 #endif