00001 #ifndef _GLUT_CORE
00002 #define _GLUT_CORE
00003 #ifdef WIN32
00004 #include <windows.h>
00005 #endif
00006
00007 #if defined(__APPLE__) || defined(MACOSX)
00008 #include <GLUT/glut.h>
00009 #else
00010 #include <GL/glut.h>
00011 #endif
00012
00014 typedef void (*DrawFunct)();
00015
00017 typedef void (*ReshapeFunct)( int Width, int Height );
00018
00020 typedef void (*MousePressFunct)( int b, int state, int x, int y );
00021
00023 typedef void (*MouseDragFunct)( int x, int y );
00024
00026 void DefaultReshape( int Width, int Height );
00027
00029 void DefaultDraw();
00030
00032 void DefaultMousePress( int b, int state, int x, int y );
00033
00035 void DefaultMouseDrag( int x, int y );
00036
00038
00042 class GLUTCore
00043 {
00044 public:
00045 GLUTCore();
00046
00048
00052 void Init( int argc, char**argv, int iWidth, int iHeight, char * sName );
00053
00055
00058 void DrawAndDoMainLoop();
00059
00061 void SetDrawFunct( DrawFunct DF ) { mDF = DF; }
00062
00064 void SetReshapeFunct( ReshapeFunct RS ) { mRS = RS; }
00065
00067 void SetMousePressFunct( MousePressFunct MP ) { mMP = MP; }
00068
00070 void SetMouseDragFunct( MouseDragFunct MD ) { mMD = MD; }
00071
00073
00076 float TackFPS();
00077
00079
00082 void SetCamDist( const float fDist ) { fGLUTCamDistance = fDist; }
00083
00085 int miWidth, miHeight;
00086
00088 int miLastMouseX, miLastMouseY;
00089
00091 int miSetMouseX, miSetMouseY;
00092
00093 int miZoomY;
00094
00096 static float fGLUTCamDistance;
00097 int GetDeltaMS() { return iDeltaMS; }
00098 private:
00100 int iDeltaMS;
00101
00103 unsigned iNumFrames;
00104
00106 unsigned iLastSecond;
00107
00109 unsigned iTmrLastSecond;
00111 unsigned iTmrLastMillisecond;
00112
00114 DrawFunct mDF;
00116 ReshapeFunct mRS;
00118 MousePressFunct mMP;
00120 MouseDragFunct mMD;
00121 };
00122
00123
00125 extern GLUTCore GLUT;
00126
00127 #endif
00128
00129