Main Page   Class Hierarchy   Compound List   File List   Compound Members  

gfxGLWindowGLUT.h

00001 //////////////////////////////////////////////////////////////////////
00002 // Copyright (c) 2002 David Pritchard <drpritch@alumni.uwaterloo.ca>
00003 // 
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public License
00006 // as published by the Free Software Foundation; either
00007 // version 2 of the License, or (at your option) any later
00008 // version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU Lesser General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU Lesser General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 
00019 #ifndef freecloth_gfx_gfxGLWindowGLUT_h
00020 #define freecloth_gfx_gfxGLWindowGLUT_h
00021 
00022 #ifndef freecloth_gfx_package_h
00023 #include <freecloth/gfx/package.h>
00024 #endif
00025 
00026 #ifndef freecloth_gfx_gfxGLWindow_h
00027 #include <freecloth/gfx/gfxGLWindow.h>
00028 #endif
00029 
00030 #ifndef freecloth_base_map
00031 #include <freecloth/base/map>
00032 #endif
00033 
00034 ////////////////////////////////////////////////////////////////////////////////
00035 // FORWARD DECLARATIONS
00036 
00037 class GfxConfig;
00038 
00039 ////////////////////////////////////////////////////////////////////////////////
00040 /*!
00041  * \class GfxGLWindowGLUT freecloth/gfx/gfxGLWindowGLUT.h
00042  * \brief Window class for GLUT
00043  *
00044  */
00045 class GfxGLWindowGLUT : public GfxGLWindow
00046 {
00047 public:
00048 
00049     //----- types and enumerations -----
00050     typedef GfxGLWindow BaseClass;
00051 
00052     //----- member functions -----
00053 
00054     GfxGLWindowGLUT(
00055         const GfxConfig&,
00056         const String& title
00057     );
00058     ~GfxGLWindowGLUT();
00059 
00060     void enableIdleEvents( bool );
00061 
00062     void close();
00063     //! Run events, forever
00064     void eventLoop();
00065     //! Can't be implemented using GLUT...
00066     void handleEvents();
00067 
00068     UInt32 getWidth() const;
00069     UInt32 getHeight() const;
00070     void swapBuffers();
00071     void postRedisplay();
00072     
00073 protected:
00074 
00075     //----- static member functions -----
00076 
00077     static KeyID translateKey( unsigned char key );
00078     static ModBitfield getModifiers();
00079     static ButtonID translateButton( Int32 button );
00080 
00081     //! Retrieve the current GLUT window
00082     static GfxGLWindowGLUT& getWindow();
00083 
00084     //! Protected, to allow GLUI to access it.
00085     static void idleCB();
00086     static void displayCB();
00087     static void keyboardCB( unsigned char key, int x, int y );
00088     static void mouseCB( int button, int state, int x, int y );
00089     static void motionCB( int x, int y );
00090     static void passiveMotionCB( int x, int y );
00091     static void specialCB( int key, int x, int y );
00092     static void reshapeCB( int w, int h );
00093 
00094     //----- member functions -----
00095 
00096     //! Virtual, to allow GLUI to override.
00097     virtual void registerIdleCB();
00098     virtual void unregisterIdleCB();
00099     virtual void registerCBs();
00100     //! See base.
00101     virtual void closeReceived();
00102 
00103     //! GLUT doesn't support some important useful events, such as closing
00104     //! a window. This allows us to handle these events.
00105     void handleMiscEvents();
00106 
00107     //----- data members -----
00108     Int32   _windowId;
00109     bool    _idleEvents;
00110 
00111 private:
00112     
00113     //----- types and enumerations -----
00114 
00115     typedef std::map<Int32,GfxGLWindowGLUT*> WindowMap;
00116 
00117     //----- member functions -----
00118 
00119     //! Disallowed.
00120     GfxGLWindowGLUT( const GfxGLWindowGLUT& );
00121     //! Disallowed.
00122     GfxGLWindowGLUT& operator = ( const GfxGLWindowGLUT& );
00123 
00124     //----- static data members -----
00125 
00126     //! Map from window ids to GfxGLWindowGLUT pointers.
00127     static WindowMap _windowMap;
00128     static UInt32 _nbIdleRegistered;
00129 
00130     //----- data members -----
00131 
00132     bool    _closeReceived;
00133     UInt32 _width;
00134     UInt32 _height;
00135 };
00136 
00137 #endif

Generated on Wed Apr 23 15:58:52 2003 for Freecloth by doxygen1.3-rc3