renderbackendsdl.h

00001 /***************************************************************************
00002  *   Copyright (C) 2005-2011 by the FIFE team                              *
00003  *   http://www.fifengine.net                                              *
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_RENDERBACKENDS_SDL_RENDERBACKENDSDL_H
00023 #define FIFE_VIDEO_RENDERBACKENDS_SDL_RENDERBACKENDSDL_H
00024 
00025 // Standard C++ library includes
00026 
00027 // 3rd party library includes
00028 
00029 // FIFE includes
00030 // These includes are split up in two parts, separated by one empty line
00031 // First block: files included from the FIFE root src directory
00032 // Second block: files included from the same folder
00033 #include "video/renderbackend.h"
00034 
00035 namespace FIFE {
00036 
00037     class ScreenMode;
00038 
00043     class RenderBackendSDL : public RenderBackend {
00044     public:
00045         RenderBackendSDL(const SDL_Color& colorkey);
00046         virtual ~RenderBackendSDL();
00047         virtual const std::string& getName() const;
00048         virtual void startFrame();
00049         virtual void endFrame();
00050         virtual void init(const std::string& driver);
00051         virtual void clearBackBuffer();
00052         virtual void setLightingModel(uint32_t lighting);
00053         virtual uint32_t getLightingModel() const;
00054         virtual void setLighting(float red, float green, float blue);
00055         virtual void resetLighting();
00056         virtual void resetStencilBuffer(uint8_t buffer);
00057         virtual void changeBlending(int32_t scr, int32_t dst);
00058 
00059         virtual void createMainScreen(const ScreenMode& mode, const std::string& title, const std::string& icon);
00060         virtual void setScreenMode(const ScreenMode& mode);
00061 
00062         virtual Image* createImage(IResourceLoader* loader = 0);
00063         virtual Image* createImage(const std::string& name, IResourceLoader* loader = 0);
00064         virtual Image* createImage(const uint8_t* data, uint32_t width, uint32_t height);
00065         virtual Image* createImage(const std::string& name, const uint8_t* data, uint32_t width, uint32_t height);
00066         virtual Image* createImage(SDL_Surface* surface);
00067         virtual Image* createImage(const std::string& name, SDL_Surface* surface);
00068 
00069         virtual void renderVertexArrays();
00070         virtual void addImageToArray(uint32_t id, const Rect& rec, float const* st, uint8_t alpha, uint8_t const* rgb);
00071         virtual void changeRenderInfos(uint16_t elements, int32_t src, int32_t dst, bool light, bool stentest, uint8_t stenref, GLConstants stenop, GLConstants stenfunc);
00072         virtual void captureScreen(const std::string& filename);
00073         virtual void captureScreen(const std::string& filename, uint32_t width, uint32_t height);
00074 
00075         virtual bool putPixel(int32_t x, int32_t y, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255);
00076         virtual void drawLine(const Point& p1, const Point& p2, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255);
00077         virtual void drawTriangle(const Point& p1, const Point& p2, const Point& p3, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255);
00078         virtual void drawRectangle(const Point& p, uint16_t w, uint16_t h, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255);
00079         virtual void fillRectangle(const Point& p, uint16_t w, uint16_t h, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255);
00080         virtual void drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4,  uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255);
00081         virtual void drawVertex(const Point& p, const uint8_t size, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255);
00082         virtual void drawLightPrimitive(const Point& p, uint8_t intensity, float radius, int32_t subdivisions, float xstretch, float ystretch, uint8_t red, uint8_t green, uint8_t blue);
00083 
00084         virtual void attachRenderTarget(ImagePtr& img, bool discard);
00085         virtual void detachRenderTarget();
00086 
00087     protected:
00088         virtual void setClipArea(const Rect& cliparea, bool clear);
00089     };
00090 
00091 }
00092 
00093 #endif