| 1 |
/*************************************************************************** |
| 2 |
* Copyright (C) 2005-2019 by the FIFE team * |
| 3 |
* http://www.fifengine.net * |
| 4 |
* This file is part of FIFE. * |
| 5 |
* * |
| 6 |
* FIFE is free software; you can redistribute it and/or * |
| 7 |
* modify it under the terms of the GNU Lesser General Public * |
| 8 |
* License as published by the Free Software Foundation; either * |
| 9 |
* version 2.1 of the License, or (at your option) any later version. * |
| 10 |
* * |
| 11 |
* This library is distributed in the hope that it will be useful, * |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * |
| 14 |
* Lesser General Public License for more details. * |
| 15 |
* * |
| 16 |
* You should have received a copy of the GNU Lesser General Public * |
| 17 |
* License along with this library; if not, write to the * |
| 18 |
* Free Software Foundation, Inc., * |
| 19 |
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * |
| 20 |
***************************************************************************/ |
| 21 |
|
| 22 |
#ifndef FIFE_VIDEO_RENDERBACKENDS_SDL_RENDERBACKENDSDL_H |
| 23 |
#define FIFE_VIDEO_RENDERBACKENDS_SDL_RENDERBACKENDSDL_H |
| 24 |
|
| 25 |
// Standard C++ library includes |
| 26 |
|
| 27 |
// 3rd party library includes |
| 28 |
|
| 29 |
// FIFE includes |
| 30 |
// These includes are split up in two parts, separated by one empty line |
| 31 |
// First block: files included from the FIFE root src directory |
| 32 |
// Second block: files included from the same folder |
| 33 |
#include "video/renderbackend.h" |
| 34 |
|
| 35 |
namespace FIFE { |
| 36 |
|
| 37 |
class ScreenMode; |
| 38 |
|
| 39 |
/** The main class of the SDL-based renderer. |
| 40 |
* |
| 41 |
* @see RenderBackend |
| 42 |
*/ |
| 43 |
class RenderBackendSDL : public RenderBackend { |
| 44 |
public: |
| 45 |
RenderBackendSDL(const SDL_Color& colorkey); |
| 46 |
virtual ~RenderBackendSDL(); |
| 47 |
virtual const std::string& getName() const; |
| 48 |
virtual void startFrame(); |
| 49 |
virtual void endFrame(); |
| 50 |
virtual void init(const std::string& driver); |
| 51 |
virtual void clearBackBuffer(); |
| 52 |
virtual void setLightingModel(uint32_t lighting); |
| 53 |
virtual uint32_t getLightingModel() const; |
| 54 |
virtual void setLighting(float red, float green, float blue); |
| 55 |
virtual void resetLighting(); |
| 56 |
virtual void resetStencilBuffer(uint8_t buffer); |
| 57 |
virtual void changeBlending(int32_t scr, int32_t dst); |
| 58 |
|
| 59 |
virtual void createMainScreen(const ScreenMode& mode, const std::string& title, const std::string& icon); |
| 60 |
virtual void setScreenMode(const ScreenMode& mode); |
| 61 |
|
| 62 |
virtual Image* createImage(IResourceLoader* loader = 0); |
| 63 |
virtual Image* createImage(const std::string& name, IResourceLoader* loader = 0); |
| 64 |
virtual Image* createImage(const uint8_t* data, uint32_t width, uint32_t height); |
| 65 |
virtual Image* createImage(const std::string& name, const uint8_t* data, uint32_t width, uint32_t height); |
| 66 |
virtual Image* createImage(SDL_Surface* surface); |
| 67 |
virtual Image* createImage(const std::string& name, SDL_Surface* surface); |
| 68 |
|
| 69 |
virtual void renderVertexArrays(); |
| 70 |
virtual void addImageToArray(uint32_t id, const Rect& rec, float const* st, uint8_t alpha, uint8_t const* rgba); |
| 71 |
virtual void changeRenderInfos(RenderDataType type, uint16_t elements, int32_t src, int32_t dst, bool light, bool stentest, uint8_t stenref, GLConstants stenop, GLConstants stenfunc, OverlayType otype = OVERLAY_TYPE_NONE); |
| 72 |
virtual void captureScreen(const std::string& filename); |
| 73 |
virtual void captureScreen(const std::string& filename, uint32_t width, uint32_t height); |
| 74 |
|
| 75 |
virtual bool putPixel(int32_t x, int32_t y, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); |
| 76 |
virtual void drawLine(const Point& p1, const Point& p2, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); |
| 77 |
virtual void drawThickLine(const Point& p1, const Point& p2, uint8_t width, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); |
| 78 |
virtual void drawPolyLine(const std::vector<Point>& points, uint8_t width, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); |
| 79 |
virtual void drawBezier(const std::vector<Point>& points, int32_t steps, uint8_t width, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); |
| 80 |
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); |
| 81 |
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); |
| 82 |
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); |
| 83 |
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); |
| 84 |
virtual void drawVertex(const Point& p, const uint8_t size, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); |
| 85 |
virtual void drawCircle(const Point& p, uint32_t radius, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); |
| 86 |
virtual void drawFillCircle(const Point& p, uint32_t radius, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); |
| 87 |
virtual void drawCircleSegment(const Point& p, uint32_t radius, int32_t sangle, int32_t eangle, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); |
| 88 |
virtual void drawFillCircleSegment(const Point& p, uint32_t radius, int32_t sangle, int32_t eangle, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); |
| 89 |
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); |
| 90 |
|
| 91 |
virtual void enableScissorTest(); |
| 92 |
virtual void disableScissorTest(); |
| 93 |
|
| 94 |
virtual void attachRenderTarget(ImagePtr& img, bool discard); |
| 95 |
virtual void detachRenderTarget(); |
| 96 |
|
| 97 |
virtual void renderGuiGeometry(const std::vector<GuiVertex>& vertices, const std::vector<int>& indices, const DoublePoint& translation, ImagePtr texture); |
| 98 |
|
| 99 |
SDL_Renderer* getRenderer() { return m_renderer; } |
| 100 |
|
| 101 |
protected: |
| 102 |
virtual void setClipArea(const Rect& cliparea, bool clear); |
| 103 |
|
| 104 |
SDL_Renderer* m_renderer; |
| 105 |
}; |
| 106 |
|
| 107 |
} |
| 108 |
|
| 109 |
#endif |