00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
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
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