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_RENDERBACKENDS_OPENGL_GLIMAGE_H 00023 #define FIFE_VIDEO_RENDERBACKENDS_OPENGL_GLIMAGE_H 00024 00025 // Standard C++ library includes 00026 #include <vector> 00027 00028 // Platform specific includes 00029 #include "util/base/fife_stdint.h" 00030 00031 // 3rd party library includes 00032 #include <SDL_video.h> 00033 00034 // FIFE includes 00035 // These includes are split up in two parts, separated by one empty line 00036 // First block: files included from the FIFE root src directory 00037 // Second block: files included from the same folder 00038 #include "video/image.h" 00039 00040 #include "fife_opengl.h" 00041 00042 namespace FIFE { 00043 // FIXME: due to image chunking issues, GLImage uses SDLImage to draw primitives on its surface 00044 // remember though that OpenGL backend is not separate thing of SDL; instead it sits on top of it 00045 class SDLImage; 00046 00047 00058 class GLImage : public Image { 00059 public: 00060 GLImage(SDL_Surface* surface); 00061 GLImage(const uint8_t* data, unsigned int width, unsigned int height); 00062 virtual ~GLImage(); 00063 void invalidate(); 00064 void render(const Rect& rect, SDL_Surface* dst, unsigned char alpha = 255); 00065 void saveImage(const std::string& filename); 00066 bool putPixel(int x, int y, int r, int g, int b, int a = 255); 00067 void drawLine(const Point& p1, const Point& p2, int r, int g, int b, int a = 255); 00068 void drawTriangle(const Point& p1, const Point& p2, const Point& p3, int r, int g, int b, int a = 255); 00069 void drawRectangle(const Point& p, uint16_t w, uint16_t h, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); 00070 void fillRectangle(const Point& p, uint16_t w, uint16_t h, uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255); 00071 void drawQuad(const Point& p1, const Point& p2, const Point& p3, const Point& p4, int r, int g, int b, int a = 255); 00072 void drawVertex(const Point& p, const uint8_t size, int r, int g, int b, int a = 255); 00073 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); 00074 00075 protected: 00076 void setClipArea(const Rect& cliparea, bool clear); 00077 00078 private: 00079 // texture coords to use 00080 float m_col_tex_coord; 00081 // @see m_col_tex_coord 00082 float m_row_tex_coord; 00083 00086 GLuint* m_textureids; 00087 00090 void cleanup(); 00091 00094 void resetGlimage(); 00095 00096 //void saveAsPng(const std::string& filename, SDL_Surface& surface); 00097 00100 void generateGLTexture(); 00101 00109 SDLImage* m_sdlimage; 00110 00111 uint32_t m_chunk_size_w; 00112 uint32_t m_chunk_size_h; 00113 00114 SDL_Color m_colorkey; 00115 }; 00116 } 00117 00118 #endif 00119 /* vim: set noexpandtab: set shiftwidth=2: set tabstop=2: */