renderbackend.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FIFE_VIDEO_RENDERBACKEND_H
00023 #define FIFE_VIDEO_RENDERBACKEND_H
00024
00025
00026 #include <string>
00027
00028
00029 #include "util/base/fife_stdint.h"
00030
00031
00032 #include <SDL.h>
00033 #include <SDL_video.h>
00034
00035
00036
00037
00038
00039 #include "util/base/singleton.h"
00040 #include "util/structures/point.h"
00041 #include "util/structures/rect.h"
00042
00043 #include "image.h"
00044
00045 namespace FIFE {
00046
00047 class Image;
00048
00050 class RenderBackend: public AbstractImage, public DynamicSingleton<RenderBackend> {
00051 public:
00055 RenderBackend(const SDL_Color& colorkey);
00056
00059 virtual ~RenderBackend();
00060
00064 virtual const std::string& getName() const = 0;
00065
00068 virtual void startFrame() = 0;
00069
00072 virtual void endFrame() = 0;
00073
00076 virtual void init() = 0;
00077
00080 virtual void deinit();
00081
00089 virtual Image* createMainScreen(unsigned int width, unsigned int height, unsigned char bitsPerPixel, bool fullscreen, const std::string& title, const std::string& icon) = 0;
00090
00097 virtual Image* createImage(const uint8_t* data, unsigned int width, unsigned int height) = 0;
00098
00104 virtual Image* createImage(SDL_Surface* surface) = 0;
00105
00109 Image* getScreenImage() const { return m_screen; };
00110
00113 void captureScreen(const std::string& filename);
00114
00115 SDL_Surface* getSurface();
00116 unsigned int getWidth() const;
00117 unsigned int getHeight() const;
00118 unsigned int getScreenWidth() const { return getWidth(); }
00119 unsigned int getScreenHeight() const { return getHeight(); }
00120 const Rect& getArea();
00121 void getPixelRGBA(int x, int y, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a);
00122 void pushClipArea(const Rect& cliparea, bool clear=true);
00123 void popClipArea();
00124 const Rect& getClipArea() const;
00125 void setAlphaOptimizerEnabled(bool enabled);
00126 bool isAlphaOptimizerEnabled();
00127 void saveImage(const std::string& filename);
00128
00134 void setChunkingSize(unsigned int size);
00135 unsigned int getChunkingSize();
00136
00139 void setColorKeyEnabled(bool colorkeyenable);
00140
00143 bool isColorKeyEnabled() const;
00144
00147 void setColorKey(const SDL_Color& colorkey);
00148
00151 const SDL_Color& getColorKey() const;
00152
00153 protected:
00154 Image* m_screen;
00155 bool m_isalphaoptimized;
00156 unsigned int m_chunkingsize;
00157 bool m_iscolorkeyenabled;
00158 SDL_Color m_colorkey;
00159 };
00160 }
00161
00162 #endif