Blender  V2.59
KX_BlenderCanvas.h
Go to the documentation of this file.
00001 /*
00002  * $Id: KX_BlenderCanvas.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 __KX_BLENDERCANVAS
00035 #define __KX_BLENDERCANVAS
00036 
00037 #ifdef WIN32
00038 #include <windows.h>
00039 #endif 
00040 
00041 #include "GL/glew.h"
00042 
00043 #include "RAS_ICanvas.h"
00044 #include "RAS_Rect.h"
00045 
00046 #include "KX_BlenderGL.h"
00047 
00048 #ifdef WITH_CXX_GUARDEDALLOC
00049 #include "MEM_guardedalloc.h"
00050 #endif
00051 
00052 struct ARegion;
00053 struct wmWindow;
00054 
00060 class KX_BlenderCanvas : public RAS_ICanvas
00061 {
00062 private:
00065         RAS_Rect m_displayarea;
00066 
00067 public:
00068         /* Construct a new canvas.
00069          * 
00070          * @param area The Blender ARegion to run the game within.
00071          */
00072         KX_BlenderCanvas(struct wmWindow* win, class RAS_Rect &rect, struct ARegion* ar);
00073         ~KX_BlenderCanvas();
00074 
00075                 void 
00076         Init(
00077         );
00078         
00079                 void 
00080         SwapBuffers(
00081         );
00082                 void 
00083         Resize(
00084                 int width,
00085                 int height
00086         );
00087 
00088                 void
00089         BeginFrame(
00090         );
00091 
00092                 void 
00093         EndFrame(
00094         );
00095 
00096                 void 
00097         ClearColor(
00098                 float r,
00099                 float g,
00100                 float b,
00101                 float a
00102         );
00103 
00104                 void 
00105         ClearBuffer(
00106                 int type
00107         );
00108 
00109                 int 
00110         GetWidth(
00111         ) const ;
00112 
00113                 int 
00114         GetHeight(
00115         ) const ;
00116 
00117                 int
00118         GetMouseX(int x
00119         );
00120 
00121                 int
00122         GetMouseY(int y
00123         );
00124 
00125                 float
00126         GetMouseNormalizedX(int x
00127         );
00128 
00129                 float
00130         GetMouseNormalizedY(int y
00131         );
00132 
00133         const
00134                 RAS_Rect &
00135         GetDisplayArea(
00136         ) const {
00137                 return m_displayarea;
00138         };
00139 
00140                 void
00141         SetDisplayArea(RAS_Rect *rect
00142         ) {
00143                 m_displayarea= *rect;
00144         };
00145 
00146                 RAS_Rect &
00147         GetWindowArea(
00148         );
00149 
00150                 void
00151         SetViewPort(
00152                 int x1, int y1,
00153                 int x2, int y2
00154         );
00155 
00156                 void 
00157         SetMouseState(
00158                 RAS_MouseState mousestate
00159         );
00160 
00161                 void 
00162         SetMousePosition(
00163                 int x,
00164                 int y
00165         );
00166 
00167                 void 
00168         MakeScreenShot(
00169                 const char* filename
00170         );
00171         
00178                 bool 
00179         BeginDraw(
00180         ) {
00181                         return true;
00182         };
00183 
00184                 void 
00185         EndDraw(
00186         ) {
00187         };
00188 
00189 private:
00191         struct wmWindow* m_win;
00192         RAS_Rect        m_frame_rect;
00193         RAS_Rect        m_area_rect;
00194         short           m_area_left;
00195         short           m_area_top;
00196 
00197 
00198 #ifdef WITH_CXX_GUARDEDALLOC
00199 public:
00200         void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_BlenderCanvas"); }
00201         void operator delete( void *mem ) { MEM_freeN(mem); }
00202 #endif
00203 };
00204 
00205 #endif // __KX_BLENDERCANVAS
00206