renderbackend.h

00001 /***************************************************************************
00002  *   Copyright (C) 2005-2008 by the FIFE team                              *
00003  *   http://www.fifengine.de                                               *
00004  *   This file is part of FIFE.                                            *
00005  *                                                                         *
00006  *   FIFE is free software; you can redistribute it and/or                 *
00007  *   modify it under the terms of the GNU Lesser General Public            *
00008  *   License as published by the Free Software Foundation; either          *
00009  *   version 2.1 of the License, or (at your option) any later version.    *
00010  *                                                                         *
00011  *   This library is distributed in the hope that it will be useful,       *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00014  *   Lesser General Public License for more details.                       *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Lesser General Public      *
00017  *   License along with this library; if not, write to the                 *
00018  *   Free Software Foundation, Inc.,                                       *
00019  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
00020  ***************************************************************************/
00021 
00022 #ifndef FIFE_VIDEO_RENDERBACKEND_H
00023 #define FIFE_VIDEO_RENDERBACKEND_H
00024 
00025 // Standard C++ library includes
00026 #include <string>
00027 
00028 // Platform specific includes
00029 #include "util/base/fife_stdint.h"
00030 
00031 // 3rd party library includes
00032 #include <SDL.h>
00033 #include <SDL_video.h>
00034 
00035 // FIFE includes
00036 // These includes are split up in two parts, separated by one empty line
00037 // First block: files included from the FIFE root src directory
00038 // Second block: files included from the same folder
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
Generated by  doxygen 1.6.2-20100208