FIFE  2008.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
renderbackendopengl.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_RENDERBACKENSD_OPENGL_RENDERBACKENDOPENGL_H
23 #define FIFE_VIDEO_RENDERBACKENSD_OPENGL_RENDERBACKENDOPENGL_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 
43  public:
44  RenderBackendOpenGL(const SDL_Color& colorkey);
45  virtual ~RenderBackendOpenGL();
46  const std::string& getName() const;
47  void startFrame();
48  void endFrame();
49  void init(const std::string& driver);
50  void clearBackBuffer();
51  void setLightingModel(unsigned int lighting);
52  unsigned int getLightingModel() const;
53  void enableLighting();
54  void disableLighting();
55  void setLighting(float red, float green, float blue, float alpha);
56  void resetLighting();
57  void enableStencilTest();
58  void disableStencilTest();
59  void setStencilTest(uint8_t stencil_ref, unsigned int stencil_op, unsigned int stencil_func);
60  void resetStencilBuffer(uint8_t buffer);
61  uint8_t getStencilRef() const;
62  void enableAlphaTest();
63  void disableAlphaTest();
64  void setAlphaTest(float ref_alpha);
65  void changeBlending(int scr, int dst);
66 
67  Image* createMainScreen(const ScreenMode& mode, const std::string& title, const std::string& icon);
68  Image* setScreenMode(const ScreenMode& mode);
69  Image* createImage(const uint8_t* data, unsigned int width, unsigned int height);
70  Image* createImage(SDL_Surface* surface);
71  bool putPixel(int x, int y, int r, int g, int b, int a = 255);
72  void drawLine(const Point& p1, const Point& p2, int r, int g, int b, int a = 255);
73  void drawTriangle(const Point& p1, const Point& p2, const Point& p3, int r, int g, int b, int a = 255);
74  void drawRectangle(const Point& p, uint16_t w, uint16_t h, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255);
75  void fillRectangle(const Point& p, uint16_t w, uint16_t h, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255);
76  void drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b, int a = 255);
77  void drawVertex(const Point& p, const uint8_t size, int r, int g, int b, int a = 255);
78  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);
79 
80  private:
81  SDL_PixelFormat m_rgba_format;
82 
83  unsigned int m_lightmodel;
84  float m_lred;
85  float m_lgreen;
86  float m_lblue;
87  float m_lalpha;
88  bool m_light_enabled;
89  bool m_stencil_enabled;
90  bool m_alpha_enabled;
91  uint8_t m_sten_ref;
92  GLint m_sten_buf;
93  unsigned int m_sten_op;
94  unsigned int m_sten_func;
95  GLenum m_blend_src;
96  GLenum m_blend_dst;
97  };
98 
99 }
100 
101 #endif
102 /* vim: set noexpandtab: set shiftwidth=2: set tabstop=2: */