Blender  V2.59
RAS_ICanvas.h
Go to the documentation of this file.
00001 /*
00002  * $Id: RAS_ICanvas.h 35072 2011-02-22 12:42:55Z 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 __RAS_ICANVAS
00035 #define __RAS_ICANVAS
00036 
00037 #ifdef WITH_CXX_GUARDEDALLOC
00038 #include "MEM_guardedalloc.h"
00039 #endif
00040 
00041 class RAS_Rect;
00042 
00046 class RAS_ICanvas
00047 {
00048 public:
00049         enum BufferType {
00050                 COLOR_BUFFER=1,
00051                 DEPTH_BUFFER=2
00052         };
00053 
00054         enum RAS_MouseState
00055         {
00056                 MOUSE_INVISIBLE=1,
00057                 MOUSE_WAIT,
00058                 MOUSE_NORMAL
00059         };
00060 
00061         virtual 
00062         ~RAS_ICanvas(
00063         ) {
00064         };
00065 
00066         virtual 
00067                 void 
00068         Init(
00069         ) = 0;
00070 
00071         virtual 
00072                 void 
00073         BeginFrame(
00074         )=0;
00075 
00076         virtual 
00077                 void 
00078         EndFrame(
00079         )=0;
00080 
00090         virtual 
00091                 bool 
00092         BeginDraw(
00093         )=0;
00094 
00099         virtual 
00100                 void 
00101         EndDraw(
00102         )=0;
00103 
00104 
00106         virtual 
00107                 void 
00108         SwapBuffers(
00109         )=0;
00110  
00111         virtual 
00112                 void 
00113         ClearBuffer(
00114                 int type
00115         )=0;
00116 
00117         virtual 
00118                 void 
00119         ClearColor(
00120                 float r,
00121                 float g,
00122                 float b,
00123                 float a
00124         )=0;
00125 
00126         virtual 
00127                 int      
00128         GetWidth(
00129         ) const = 0;
00130 
00131         virtual 
00132                 int      
00133         GetHeight(
00134         ) const = 0;
00135 
00136         virtual
00137                 int
00138         GetMouseX( int x
00139         )=0;
00140 
00141         virtual
00142                 int
00143         GetMouseY( int y
00144         )= 0;
00145 
00146         virtual
00147                 float
00148         GetMouseNormalizedX( int x
00149         )=0;
00150 
00151         virtual
00152                 float
00153         GetMouseNormalizedY( int y
00154         )= 0;
00155 
00156         virtual 
00157                 const RAS_Rect &
00158         GetDisplayArea(
00159         ) const = 0;
00160 
00161         virtual
00162                 void
00163         SetDisplayArea(RAS_Rect *rect
00164         ) = 0;
00165 
00169         virtual
00170                 RAS_Rect &
00171         GetWindowArea(
00172         ) = 0;
00173 
00178         virtual
00179                 void
00180         SetViewPort(
00181                 int x1, int y1,
00182                 int x2, int y2
00183         ) = 0; 
00184 
00185         virtual 
00186                 void 
00187         SetMouseState(
00188                 RAS_MouseState mousestate
00189         )=0;
00190 
00191         virtual 
00192                 void 
00193         SetMousePosition(
00194                 int x,
00195                 int y
00196         )=0;
00197 
00198         virtual
00199                 RAS_MouseState
00200         GetMouseState()
00201         {
00202                 return m_mousestate;
00203         }
00204 
00205         virtual 
00206                 void 
00207         MakeScreenShot(
00208                 const char* filename
00209         )=0;
00210         
00211 protected:
00212         RAS_MouseState m_mousestate;
00213         
00214 #ifdef WITH_CXX_GUARDEDALLOC
00215 public:
00216         void *operator new(size_t num_bytes) { return MEM_mallocN(num_bytes, "GE:RAS_ICanvas"); }
00217         void operator delete( void *mem ) { MEM_freeN(mem); }
00218 #endif
00219 };
00220 
00221 #endif //__RAS_ICANVAS
00222