|
Blender
V2.59
|
00001 00029 #ifndef NAN_INCLUDED_GlutDrawer 00030 #define NAN_INCLUDED_GlutDrawer 00031 00032 #include "MEM_NonCopyable.h" 00033 #include "MEM_SmartPtr.h" 00034 00035 // So pissed off with Glut callback stuff 00036 // that is impossible to call objects unless they are global 00037 00038 // inherit from GlutDrawer and installl the drawer in the singleton 00039 // class GlutDrawManager. 00040 00041 class GlutDrawer { 00042 public : 00043 00044 virtual 00045 void 00046 Draw( 00047 )= 0; 00048 00049 virtual 00050 ~GlutDrawer( 00051 ){}; 00052 }; 00053 00054 class GlutDrawManager : public MEM_NonCopyable{ 00055 00056 public : 00057 00058 static 00059 GlutDrawManager * 00060 Instance( 00061 ); 00062 00063 // this is the function you should pass to glut 00064 00065 static 00066 void 00067 Draw( 00068 ); 00069 00070 void 00071 InstallDrawer( 00072 GlutDrawer * 00073 ); 00074 00075 void 00076 ReleaseDrawer( 00077 ); 00078 00079 ~GlutDrawManager( 00080 ); 00081 00082 private : 00083 00084 GlutDrawManager ( 00085 ) : 00086 m_drawer (0) 00087 { 00088 }; 00089 00090 GlutDrawer * m_drawer; 00091 00092 static MEM_SmartPtr<GlutDrawManager> m_s_instance; 00093 }; 00094 00095 #endif 00096