FIFE 2008.0
|
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_RENDERBACKENSD_OPENGL_RENDERBACKENDOPENGL_H 00023 #define FIFE_VIDEO_RENDERBACKENSD_OPENGL_RENDERBACKENDOPENGL_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 00042 class RenderBackendOpenGL : public RenderBackend { 00043 public: 00044 RenderBackendOpenGL(const SDL_Color& colorkey); 00045 virtual ~RenderBackendOpenGL(); 00046 const std::string& getName() const; 00047 void startFrame(); 00048 void endFrame(); 00049 void init(const std::string& driver); 00050 void clearBackBuffer(); 00051 void setLightingModel(unsigned int lighting); 00052 unsigned int getLightingModel() const; 00053 void enableLighting(); 00054 void disableLighting(); 00055 void setLighting(float red, float green, float blue, float alpha); 00056 void resetLighting(); 00057 void enableStencilTest(); 00058 void disableStencilTest(); 00059 void setStencilTest(uint8_t stencil_ref, unsigned int stencil_op, unsigned int stencil_func); 00060 void resetStencilBuffer(uint8_t buffer); 00061 uint8_t getStencilRef() const; 00062 void enableAlphaTest(); 00063 void disableAlphaTest(); 00064 void setAlphaTest(float ref_alpha); 00065 void changeBlending(int scr, int dst); 00066 00067 Image* createMainScreen(const ScreenMode& mode, const std::string& title, const std::string& icon); 00068 Image* setScreenMode(const ScreenMode& mode); 00069 Image* createImage(const uint8_t* data, unsigned int width, unsigned int height); 00070 Image* createImage(SDL_Surface* surface); 00071 bool putPixel(int x, int y, int r, int g, int b, int a = 255); 00072 void drawLine(const Point& p1, const Point& p2, int r, int g, int b, int a = 255); 00073 void drawTriangle(const Point& p1, const Point& p2, const Point& p3, int r, int g, int b, int a = 255); 00074 void drawRectangle(const Point& p, uint16_t w, uint16_t h, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); 00075 void fillRectangle(const Point& p, uint16_t w, uint16_t h, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); 00076 void drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b, int a = 255); 00077 void drawVertex(const Point& p, const uint8_t size, int r, int g, int b, int a = 255); 00078 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); 00079 00080 private: 00081 SDL_PixelFormat m_rgba_format; 00082 00083 unsigned int m_lightmodel; 00084 float m_lred; 00085 float m_lgreen; 00086 float m_lblue; 00087 float m_lalpha; 00088 bool m_light_enabled; 00089 bool m_stencil_enabled; 00090 bool m_alpha_enabled; 00091 uint8_t m_sten_ref; 00092 GLint m_sten_buf; 00093 unsigned int m_sten_op; 00094 unsigned int m_sten_func; 00095 GLenum m_blend_src; 00096 GLenum m_blend_dst; 00097 }; 00098 00099 } 00100 00101 #endif 00102 /* vim: set noexpandtab: set shiftwidth=2: set tabstop=2: */