FIFE 2008.0
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 #include <vector>
00028 
00029 // Platform specific includes
00030 #include "util/base/fife_stdint.h"
00031 
00032 // 3rd party library includes
00033 #include <SDL.h>
00034 #include <SDL_video.h>
00035 
00036 // FIFE includes
00037 // These includes are split up in two parts, separated by one empty line
00038 // First block: files included from the FIFE root src directory
00039 // Second block: files included from the same folder
00040 #include "util/base/singleton.h"
00041 #include "util/structures/point.h"
00042 #include "util/structures/rect.h"
00043 #include "video/devicecaps.h"
00044 
00045 #include "image.h"
00046 
00047 namespace FIFE {
00048 
00049     class Image;
00050 
00052     class RenderBackend: public AbstractImage, public DynamicSingleton<RenderBackend> {
00053     public:
00057         RenderBackend(const SDL_Color& colorkey);
00058 
00061         virtual ~RenderBackend();
00062 
00066         virtual const std::string& getName() const = 0;
00067 
00070         virtual void startFrame() = 0;
00071 
00074         virtual void endFrame() = 0;
00075 
00078         virtual void init(const std::string& driver) = 0;
00079 
00082         virtual void clearBackBuffer() = 0;
00083 
00086         virtual void setLightingModel(unsigned int lighting) = 0;
00087 
00090         virtual unsigned int getLightingModel() const = 0;
00091 
00094         virtual void enableLighting() = 0;
00095 
00098         virtual void disableLighting() = 0;
00099 
00102         virtual void setLighting(float red, float green, float blue, float alpha) = 0;
00103 
00106         virtual void resetLighting() = 0;
00107 
00110         virtual void enableStencilTest() = 0;
00111 
00114         virtual void disableStencilTest() = 0;
00115 
00118         virtual void setStencilTest(Uint8 stencil_ref, unsigned int stencil_op, unsigned int stencil_func) = 0;
00119 
00122         virtual void resetStencilBuffer(Uint8 buffer) = 0;
00123 
00126         virtual Uint8 getStencilRef() const = 0;
00127 
00130         virtual void enableAlphaTest() = 0;
00131 
00134         virtual void disableAlphaTest() = 0;
00135 
00138         virtual void setAlphaTest(float ref_alpha) = 0;
00139 
00142         virtual void changeBlending(int scr, int dst) = 0;
00143 
00146         virtual void deinit();
00147 
00154         virtual Image* createMainScreen(const ScreenMode& mode, const std::string& title, const std::string& icon) = 0;
00155 
00160         virtual Image* setScreenMode(const ScreenMode& mode) = 0;
00161 
00168         virtual Image* createImage(const uint8_t* data, unsigned int width, unsigned int height) = 0;
00169 
00175         virtual Image* createImage(SDL_Surface* surface) = 0;
00176 
00180         Image* getScreenImage() const { return m_screen; };
00181 
00184         void captureScreen(const std::string& filename);
00185 
00186         SDL_Surface* getSurface();
00187 
00191         const ScreenMode& getCurrentScreenMode() const;
00192 
00193         unsigned int getWidth() const;
00194         unsigned int getHeight() const;
00195         unsigned int getScreenWidth() const { return getWidth(); }
00196         unsigned int getScreenHeight() const { return getHeight(); }
00197         const Rect& getArea();
00198         void getPixelRGBA(int x, int y, uint8_t* r, uint8_t* g, uint8_t* b, uint8_t* a);
00199         void pushClipArea(const Rect& cliparea, bool clear=true);
00200         void popClipArea();
00201         const Rect& getClipArea() const;
00202         void setAlphaOptimizerEnabled(bool enabled);
00203         bool isAlphaOptimizerEnabled();
00204         void saveImage(const std::string& filename);
00205 
00208         void setColorKeyEnabled(bool colorkeyenable);
00209 
00212         bool isColorKeyEnabled() const;
00213 
00216         void setColorKey(const SDL_Color& colorkey);
00217 
00220         const SDL_Color& getColorKey() const;
00221 
00222     protected:
00223         Image* m_screen;
00224         bool m_isalphaoptimized;
00225         unsigned int m_chunkingsize;
00226         bool m_iscolorkeyenabled;
00227         SDL_Color m_colorkey;
00228         ScreenMode m_screenMode;
00229     };
00230 }
00231 
00232 #endif
 All Classes Namespaces Functions Variables Enumerations Enumerator