00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef _VRJ_GL_PIPE_H_
00034 #define _VRJ_GL_PIPE_H_
00035
00036 #include <vrj/vrjConfig.h>
00037 #include <vector>
00038
00039 #include <vrj/Draw/OGL/GlWindow.h>
00040 #include <vrj/Draw/OGL/GlDrawManager.h>
00041 #include <vpr/Sync/CondVar.h>
00042 #include <vpr/Sync/Semaphore.h>
00043
00044
00045 namespace vrj
00046 {
00047 class GlDrawManager;
00056 class VJ_CLASS_API GlPipe
00057 {
00058 public:
00067 GlPipe(int num, GlDrawManager* glMgr)
00068 : mActiveThread(NULL)
00069 , mPipeNum(num)
00070 , controlExit(0)
00071 , glManager(glMgr)
00072 , renderTriggerSema(0)
00073 , renderCompleteSema(0)
00074 , swapTriggerSema(0)
00075 , swapCompleteSema(0)
00076 {
00077 mThreadRunning = false;
00078 }
00079
00089 int start();
00090
00096 void controlLoop(void* nullParam);
00097
00102 void stop()
00103 { controlExit = 1; }
00104
00105 public:
00111 void triggerRender();
00112
00118 void completeRender();
00119
00125 void triggerSwap();
00126
00132 void completeSwap();
00133
00134 public:
00135
00140 void addWindow(GlWindow* win);
00141
00146 void removeWindow(GlWindow* win);
00147
00149 int hasWindows()
00150 {
00151 return ( (mNewWins.size() > 0) || (mOpenWins.size() > 0));
00152 }
00153
00155 std::vector<GlWindow*> getOpenWindows()
00156 {
00157 return mOpenWins;
00158 }
00159
00160 private:
00166 void checkForNewWindows();
00167
00173 void checkForWindowsToClose();
00174
00179 void renderWindow(GlWindow* win);
00180
00182 void swapWindowBuffers(GlWindow* win);
00183
00188 void finishWindowSetup(GlWindow* win);
00189
00190 GlPipe(const GlPipe& o) {;}
00191 void operator=(const GlPipe& o) {;}
00192
00193 private:
00194 vpr::Thread* mActiveThread;
00195 bool mThreadRunning;
00197 int mPipeNum;
00199 std::vector<GlWindow*> mNewWins;
00200 vpr::Mutex mNewWinLock;
00202 std::vector<GlWindow*> mOpenWins;
00203 vpr::Mutex mOpenWinLock;
00205 std::vector<GlWindow*> mClosingWins;
00206 vpr::Mutex mClosingWinLock;
00208 int controlExit;
00210 GlDrawManager* glManager;
00213 vpr::Semaphore renderTriggerSema;
00214 vpr::Semaphore renderCompleteSema;
00215 vpr::Semaphore swapTriggerSema;
00216 vpr::Semaphore swapCompleteSema;
00217 };
00218
00219 }
00220
00221 #endif