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