00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FIFE_VIDEO_RENDERBACKENSD_OPENGL_RENDERBACKENDOPENGL_H
00023 #define FIFE_VIDEO_RENDERBACKENSD_OPENGL_RENDERBACKENDOPENGL_H
00024
00025
00026
00027
00028
00029
00030
00031
00032
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