Blender V2.61 - r43446

KX_BlenderCanvas.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  */
00027 
00032 #ifndef __KX_BLENDERCANVAS
00033 #define __KX_BLENDERCANVAS
00034 
00035 #ifdef WIN32
00036 #include <windows.h>
00037 #endif 
00038 
00039 #include "GL/glew.h"
00040 
00041 #include "RAS_ICanvas.h"
00042 #include "RAS_Rect.h"
00043 
00044 #include "KX_BlenderGL.h"
00045 
00046 #ifdef WITH_CXX_GUARDEDALLOC
00047 #include "MEM_guardedalloc.h"
00048 #endif
00049 
00050 struct ARegion;
00051 struct wmWindow;
00052 
00058 class KX_BlenderCanvas : public RAS_ICanvas
00059 {
00060 private:
00063     RAS_Rect m_displayarea;
00064 
00065 public:
00066     /* Construct a new canvas.
00067      * 
00068      * @param area The Blender ARegion to run the game within.
00069      */
00070     KX_BlenderCanvas(struct wmWindow* win, class RAS_Rect &rect, struct ARegion* ar);
00071     ~KX_BlenderCanvas();
00072 
00073         void 
00074     Init(
00075     );
00076     
00077         void 
00078     SwapBuffers(
00079     );
00080         void 
00081     Resize(
00082         int width,
00083         int height
00084     );
00085 
00086         void
00087     BeginFrame(
00088     );
00089 
00090         void 
00091     EndFrame(
00092     );
00093 
00094         void 
00095     ClearColor(
00096         float r,
00097         float g,
00098         float b,
00099         float a
00100     );
00101 
00102         void 
00103     ClearBuffer(
00104         int type
00105     );
00106 
00107         int 
00108     GetWidth(
00109     ) const ;
00110 
00111         int 
00112     GetHeight(
00113     ) const ;
00114 
00115         int
00116     GetMouseX(int x
00117     );
00118 
00119         int
00120     GetMouseY(int y
00121     );
00122 
00123         float
00124     GetMouseNormalizedX(int x
00125     );
00126 
00127         float
00128     GetMouseNormalizedY(int y
00129     );
00130 
00131     const
00132         RAS_Rect &
00133     GetDisplayArea(
00134     ) const {
00135         return m_displayarea;
00136     };
00137 
00138         void
00139     SetDisplayArea(RAS_Rect *rect
00140     ) {
00141         m_displayarea= *rect;
00142     };
00143 
00144         RAS_Rect &
00145     GetWindowArea(
00146     );
00147 
00148         void
00149     SetViewPort(
00150         int x1, int y1,
00151         int x2, int y2
00152     );
00153 
00154         void 
00155     SetMouseState(
00156         RAS_MouseState mousestate
00157     );
00158 
00159         void 
00160     SetMousePosition(
00161         int x,
00162         int y
00163     );
00164 
00165         void 
00166     MakeScreenShot(
00167         const char* filename
00168     );
00169     
00176         bool 
00177     BeginDraw(
00178     ) {
00179             return true;
00180     };
00181 
00182         void 
00183     EndDraw(
00184     ) {
00185     };
00186 
00187 private:
00189     struct wmWindow* m_win;
00190     RAS_Rect    m_frame_rect;
00191     RAS_Rect    m_area_rect;
00192     short       m_area_left;
00193     short       m_area_top;
00194 
00195 
00196 #ifdef WITH_CXX_GUARDEDALLOC
00197 public:
00198     void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:KX_BlenderCanvas"); }
00199     void operator delete( void *mem ) { MEM_freeN(mem); }
00200 #endif
00201 };
00202 
00203 #endif // __KX_BLENDERCANVAS
00204