|
Blender
V2.59
|
00001 /* 00002 * $Id: GPC_Canvas.h 35063 2011-02-22 10:33:14Z jesterking $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program 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 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00021 * All rights reserved. 00022 * 00023 * The Original Code is: all of this file. 00024 * 00025 * Contributor(s): none yet. 00026 * 00027 * ***** END GPL LICENSE BLOCK ***** 00028 */ 00029 00034 #ifndef _GPC_CANVAS_H_ 00035 #define _GPC_CANVAS_H_ 00036 00037 #include "RAS_ICanvas.h" 00038 #include "RAS_Rect.h" 00039 00040 #ifdef WIN32 00041 #pragma warning (disable:4786) // suppress stl-MSVC debug info warning 00042 #include <windows.h> 00043 #endif // WIN32 00044 00045 #include "GL/glew.h" 00046 00047 #include <map> 00048 00049 00050 class GPC_Canvas : public RAS_ICanvas 00051 { 00052 public: 00056 typedef enum { 00057 alignTopLeft, 00058 alignBottomRight 00059 } TBannerAlignment; 00060 00061 typedef int TBannerId; 00062 00063 protected: 00067 typedef struct { 00069 TBannerAlignment alignment; 00071 bool enabled; 00073 unsigned int displayWidth; 00075 unsigned int displayHeight; 00077 unsigned int imageWidth; 00079 unsigned int imageHeight; 00081 unsigned char* imageData; 00083 unsigned int textureName; 00084 } TBannerData; 00085 typedef std::map<TBannerId, TBannerData> TBannerMap; 00086 00088 int m_width; 00090 int m_height; 00093 RAS_Rect m_displayarea; 00094 00096 TBannerMap m_banners; 00098 bool m_bannersEnabled; 00099 00100 public: 00101 00102 GPC_Canvas(int width, int height); 00103 00104 virtual ~GPC_Canvas(); 00105 00106 void Resize(int width, int height); 00107 00108 00113 int 00114 GetWidth( 00115 ) const { 00116 return m_width; 00117 } 00118 00119 int 00120 GetHeight( 00121 ) const { 00122 return m_height; 00123 } 00124 00125 const 00126 RAS_Rect & 00127 GetDisplayArea( 00128 ) const { 00129 return m_displayarea; 00130 }; 00131 00132 void 00133 SetDisplayArea( 00134 RAS_Rect *rect 00135 ) { 00136 m_displayarea= *rect; 00137 }; 00138 00139 RAS_Rect & 00140 GetWindowArea( 00141 ) { 00142 return m_displayarea; 00143 } 00144 00145 void 00146 BeginFrame( 00147 ) {}; 00148 00152 void 00153 EndFrame( 00154 ); 00155 00156 void SetViewPort(int x1, int y1, int x2, int y2); 00157 00158 void ClearColor(float r, float g, float b, float a); 00159 00165 void SetMouseState(RAS_MouseState mousestate) 00166 { 00167 // not yet 00168 } 00169 00170 void SetMousePosition(int x, int y) 00171 { 00172 // not yet 00173 } 00174 00175 virtual void MakeScreenShot(const char* filename); 00176 00177 void ClearBuffer(int type); 00178 00195 TBannerId AddBanner( 00196 unsigned int bannerWidth, unsigned int bannerHeight, 00197 unsigned int imageWidth, unsigned int imageHeight, 00198 unsigned char* imageData, TBannerAlignment alignment = alignTopLeft, 00199 bool enabled = true); 00200 00205 void DisposeBanner(TBannerId id); 00206 00210 void DisposeAllBanners(); 00211 00217 void SetBannerEnabled(TBannerId id, bool enabled = true); 00218 00223 void SetBannerDisplayEnabled(bool enabled = true); 00224 00225 protected: 00230 void DisposeBanner(TBannerData& banner); 00231 00235 void DrawAllBanners(void); 00236 00240 void DrawBanner(TBannerData& banner); 00241 00242 struct CanvasRenderState { 00243 int oldLighting; 00244 int oldDepthTest; 00245 int oldFog; 00246 int oldTexture2D; 00247 int oldBlend; 00248 int oldBlendSrc; 00249 int oldBlendDst; 00250 float oldColor[4]; 00251 int oldWriteMask; 00252 }; 00253 00254 void 00255 PushRenderState( 00256 CanvasRenderState & render_state 00257 ); 00258 void 00259 PopRenderState( 00260 const CanvasRenderState & render_state 00261 ); 00262 00267 void 00268 SetOrthoProjection( 00269 ); 00270 00271 static TBannerId s_bannerId; 00272 }; 00273 00274 #endif // _GPC_CANVAS_H_ 00275