FIFE  2008.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
renderbackendsdl.h
1 /***************************************************************************
2  * Copyright (C) 2005-2008 by the FIFE team *
3  * http://www.fifengine.de *
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 
44  public:
45  RenderBackendSDL(const SDL_Color& colorkey);
46  virtual ~RenderBackendSDL();
47  const std::string& getName() const;
48 
49  void startFrame();
50  void endFrame();
51  void init(const std::string& driver);
52  void clearBackBuffer();
53  void setLightingModel(unsigned int lighting);
54  unsigned int getLightingModel() const;
55  void enableLighting();
56  void disableLighting();
57  void setLighting(float red, float green, float blue, float alpha);
58  void resetLighting();
59  void enableStencilTest();
60  void disableStencilTest();
61  void setStencilTest(uint8_t stencil_ref, unsigned int stencil_op, unsigned int stencil_func);
62  void resetStencilBuffer(uint8_t buffer);
63  uint8_t getStencilRef() const;
64  void enableAlphaTest();
65  void disableAlphaTest();
66  void setAlphaTest(float ref_alpha);
67  void changeBlending(int scr, int dst);
68 
69  Image* createMainScreen(const ScreenMode& mode, const std::string& title, const std::string& icon);
70  Image* setScreenMode(const ScreenMode& mode);
71  Image* createImage(const uint8_t* data, unsigned int width, unsigned int height);
72  Image* createImage(SDL_Surface* surface);
73  bool putPixel(int x, int y, int r, int g, int b, int a = 255);
74  void drawLine(const Point& p1, const Point& p2, int r, int g, int b, int a = 255);
75  void drawTriangle(const Point& p1, const Point& p2, const Point& p3, int r, int g, int b, int a = 255);
76  void drawRectangle(const Point& p, uint16_t w, uint16_t h, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255);
77  void fillRectangle(const Point& p, uint16_t w, uint16_t h, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255);
78  void drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b, int a = 255);
79  void drawVertex(const Point& p, const uint8_t size, int r, int g, int b, int a = 255);
80  void drawLightPrimitive(const Point& p, uint8_t intensity, float radius, int subdivisions, float xstretch, float ystretch, uint8_t red, uint8_t green, uint8_t blue);
81  };
82 
83 }
84 
85 #endif