src/render/rGLuintObject.h

Go to the documentation of this file.
00001 /*
00002 
00003 *************************************************************************
00004 
00005 ArmageTron -- Just another Tron Lightcycle Game in 3D.
00006 Copyright (C) 2006, Armagetron Advanced Development Team  
00007 
00008 **************************************************************************
00009 
00010 This program is free software; you can redistribute it and/or
00011 modify it under the terms of the GNU General Public License
00012 as published by the Free Software Foundation; either version 2
00013 of the License, or (at your option) any later version.
00014 
00015 This program is distributed in the hope that it will be useful,
00016 but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00023   
00024 ***************************************************************************
00025 
00026 */
00027 
00028 #ifndef ArmageTron_GLUINTOBJECT_H
00029 #define ArmageTron_GLUINTOBJECT_H
00030 
00031 #include "rGL.h"
00032 #include "tError.h"
00033 
00035 class rGLuintObject
00036 {
00037 public:
00038     rGLuintObject();        
00039 
00040     operator GLuint();      
00041     bool IsValid() const;       
00042 
00043     virtual ~rGLuintObject();  
00044 
00045     void Gen();     
00046     void Delete();      
00047 protected:
00048     rGLuintObject( rGLuintObject const & );                 
00049     rGLuintObject & operator =( rGLuintObject const & );    
00050 
00051     GLuint object_;                 
00052 private:
00053     virtual void DoGen() = 0;       
00054     virtual void DoDelete() = 0;    
00055 };
00056 
00058 class rGluintObjectDummy: public rGLuintObject
00059 {
00060 public:
00061     ~rGluintObjectDummy(){ Delete(); }
00062 private:
00063     // the following operations are not supported, wrap your code in #ifdef HAVE_GLEW
00064     virtual void DoGen(){ tASSERT(0); }
00065     virtual void DoDelete(){  tASSERT(0); }
00066 };
00067 
00071 #ifndef DEDICATED
00072 #define rDEFINE_GLUINTOBJECT( CLASS, FUNCTION ) \
00073 class CLASS: public rGLuintObject \
00074 { \
00075 public: \
00076         ~CLASS(){ Delete(); } \
00077 private: \
00078         virtual void DoGen(){ glGen##FUNCTION( 1, &object_ ); } \
00079         virtual void DoDelete(){ glDelete##FUNCTION( 1, &object_ ); } \
00080 }
00081 #else // DEDICATED
00082 // safe dummy
00083 #define rDEFINE_GLUINTOBJECT( CLASS, FUNCTION ) typedef rGluintObjectDummy CLASS
00084 #endif
00085 
00089 #ifdef HAVE_GLEW
00090 #define rDEFINE_GLUINTOBJECT_EXT(CLASS, FUNCTION ) rDEFINE_GLUINTOBJECT( CLASS, FUNCTION )
00091 #else // HAVE_GLEW, define unusable dummy object
00092 #define rDEFINE_GLUINTOBJECT_EXT( CLASS, FUNCTION ) typedef rGluintObjectDummy CLASS
00093 #endif // HAVE_GLEW
00094 
00096 rDEFINE_GLUINTOBJECT( rGLuintObjectTexture, Textures );
00097 
00099 rDEFINE_GLUINTOBJECT_EXT( rGLuintObjectRenderbuffer, RenderbuffersEXT );
00100 
00102 rDEFINE_GLUINTOBJECT_EXT( rGLuintObjectFramebuffer, FramebuffersEXT );
00103 
00104 #endif
00105 
00106 

Generated on Sat Mar 15 22:55:52 2008 for Armagetron Advanced by  doxygen 1.5.4