random_utils/include/random_utils/ThreadSafeCanvas.h

Go to the documentation of this file.
00001 #ifndef _RU_THREADSAFE_CANVAS_H_
00002 #define _RU_THREADSAFE_CANVAS_H_
00003 
00004 #include <vrs/glut/glutcanvas.h>
00005 
00006 #include "ThreadSafeObject.h"
00007 
00008 #include <SDL.h>
00009 
00010 namespace random_utils
00011 {
00012 
00019 class ThreadSafeCanvas : public VRS::GlutCanvas, public ThreadSafeObject
00020 {
00021     SDL_mutex*  m_canvasRendering;
00022 
00023     SDL_cond*   m_finishedRenderingCondition;
00024     SDL_mutex*  m_finishedRenderingMutex;
00025     SDL_cond*   m_wakeUpCondition;
00026     SDL_mutex*  m_requestMutex;
00027 
00028     bool m_sleepRequested;
00029 
00031     static ThreadSafeCanvas*    m_instance;
00032     
00033     bool m_breakOut;
00034 
00035 public:
00040     ThreadSafeCanvas(const std::string& windowName,
00041                      unsigned int width, unsigned int height, int properties);
00042 
00043     virtual ~ThreadSafeCanvas();
00044 
00050     void finishRedisplay();
00051 
00056     void sleep();
00057 
00061     void wakeUp();
00062 
00068     static ThreadSafeCanvas* get()
00069     {
00070         return m_instance;
00071     }
00072     
00077     void breakOut();
00078 };
00079 
00080 }
00081 
00082 #endif

Generated on Fri May 11 21:01:58 2007 for Random Racer by  doxygen 1.5.1