#include <GlPipe.h>
Collaboration diagram for vrj::GlPipe:

Public Methods | |
| GlPipe (int num, GlDrawManager *glMgr) | |
| Constructor. More... | |
| int | start () |
| Starts the pipe running. More... | |
| void | controlLoop (void *nullParam) |
| The main loop routine. More... | |
| void | stop () |
| Stops the pipe. More... | |
| void | triggerRender () |
| Triggers rendering of the pipe to start. More... | |
| void | completeRender () |
| Blocks until rendering of the windows is completed. More... | |
| void | triggerSwap () |
| Triggers swapping of all pipe's windows. More... | |
| void | completeSwap () |
| Blocks until swapping of the windows is completed. More... | |
| void | addWindow (GlWindow *win) |
| Adds a GLWindow to the window list. More... | |
| void | removeWindow (GlWindow *win) |
| Removes a GLWindow from the window list. More... | |
| int | hasWindows () |
| Returns true if pipe has any windows. More... | |
| std::vector< GlWindow * > | getOpenWindows () |
| Return a list of open windows. More... | |
This class can be used to group glWindows to render efficiently on one pipe (SGI terminology).
Definition at line 56 of file GlPipe.h.
|
||||||||||||
|
Constructor.
Definition at line 67 of file GlPipe.h.
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 }
|
|
|
Starts the pipe running.
Definition at line 63 of file GlPipe.cpp. References vrjDBG_DRAW_MGR.
00064 {
00065 vprASSERT(mThreadRunning == false); // We should not be running yet
00066
00067 // Create a new thread to call the control loop
00068 vpr::ThreadMemberFunctor<GlPipe>* memberFunctor =
00069 new vpr::ThreadMemberFunctor<GlPipe>(this, &GlPipe::controlLoop, NULL);
00070
00071 mActiveThread = new vpr::Thread(memberFunctor);
00072
00073 vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_CONFIG_LVL)
00074 << "vjGlPipe::start: Started control loop. " << mActiveThread
00075 << std::endl << vprDEBUG_FLUSH;
00076 return 1; // XXX: Is this always true?
00077 }
|
|
|
The main loop routine.
-Checks for new windows Definition at line 160 of file GlPipe.cpp.
00161 {
00162 boost::ignore_unused_variable_warning(nullParam);
00163 mThreadRunning = true; // We are running so set flag
00164 // Loop until flag set
00165 while (!controlExit)
00166 {
00167 checkForWindowsToClose(); // Checks for closing windows
00168 checkForNewWindows(); // Checks for new windows to open
00169
00170 // --- handle EVENTS for the windows --- //
00171 // XXX: This may have to be here because of need to get open window event (Win32)
00172 // otherwise I would like to move it to being after the swap to get better performance
00173 {
00174 for(unsigned int winId=0;winId<mOpenWins.size();winId++)
00175 mOpenWins[winId]->checkEvents();
00176 }
00177
00178 // --- RENDER the windows ---- //
00179 {
00180 renderTriggerSema.acquire();
00181
00182 GlApp* the_app = glManager->getApp();
00183
00184 // --- pipe PRE-draw function ---- //
00185 the_app->pipePreDraw(); // Can't get a context since I may not be guaranteed a window
00186
00187 // Render the windows
00188 for (unsigned int winId=0;winId < mOpenWins.size();winId++) {
00189 renderWindow(mOpenWins[winId]);
00190 }
00191 renderCompleteSema.release();
00192 }
00193
00194 // ----- SWAP the windows ------ //
00195 {
00196 swapTriggerSema.acquire();
00197
00198 // Swap all the windows
00199 for(unsigned int winId=0;winId < mOpenWins.size();winId++)
00200 {
00201 swapWindowBuffers(mOpenWins[winId]);
00202 }
00203
00204 swapCompleteSema.release();
00205 }
00206 }
00207
00208 mThreadRunning = false; // We are not running
00209 }
|
|
|
Stops the pipe.
Definition at line 102 of file GlPipe.h.
00103 { controlExit = 1; } // Set the control loop exit flag
|
|
|
Triggers rendering of the pipe to start.
Definition at line 83 of file GlPipe.cpp. References vrjDBG_DRAW_MGR.
00084 {
00085 //vprASSERT(mThreadRunning == true); // We must be running
00086 while(!mThreadRunning)
00087 {
00088 vprDEBUG(vrjDBG_DRAW_MGR,vprDBG_HVERB_LVL) << "Waiting in for thread to start triggerRender.\n" << vprDEBUG_FLUSH;
00089 vpr::Thread::yield();
00090 }
00091
00092 renderTriggerSema.release();
00093 }
|
|
|
Blocks until rendering of the windows is completed.
Definition at line 99 of file GlPipe.cpp.
00100 {
00101 vprASSERT(mThreadRunning == true); // We must be running
00102
00103 renderCompleteSema.acquire();
00104 }
|
|
|
Triggers swapping of all pipe's windows.
Definition at line 107 of file GlPipe.cpp.
00108 {
00109 vprASSERT(mThreadRunning == true);
00110 swapTriggerSema.release();
00111 }
|
|
|
Blocks until swapping of the windows is completed.
Definition at line 114 of file GlPipe.cpp.
00115 {
00116 vprASSERT(mThreadRunning == true);
00117 swapCompleteSema.acquire();
00118 }
|
|
|
Adds a GLWindow to the window list. Control loop must now open the window on the next frame. Definition at line 125 of file GlPipe.cpp. References vrjDBG_DRAW_MGR.
00126 {
00127 vpr::Guard<vpr::Mutex> guardNew(mNewWinLock); // Protect the data
00128 vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_STATE_LVL)
00129 << "vjGlPipe::addWindow: Pipe: " << mPipeNum
00130 << " adding window (to new wins):\n" << win
00131 << std::endl << vprDEBUG_FLUSH;
00132 mNewWins.push_back(win);
00133 }
|
|
|
Removes a GLWindow from the window list.
Definition at line 139 of file GlPipe.cpp. References vrjDBG_DRAW_MGR.
00140 {
00141 vpr::Guard<vpr::Mutex> guardClosing(mClosingWinLock);
00142 vprDEBUG(vrjDBG_DRAW_MGR, vprDBG_STATE_LVL)
00143 << "vjGlPipe:: removeWindow: Pipe: " << mPipeNum
00144 << " window added to closingWins.\n" << win
00145 << std::endl << vprDEBUG_FLUSH;
00146 mClosingWins.push_back(win);
00147 }
|
|
|
Returns true if pipe has any windows.
Definition at line 149 of file GlPipe.h.
00150 {
00151 return ( (mNewWins.size() > 0) || (mOpenWins.size() > 0));
00152 }
|
|
|
Return a list of open windows.
Definition at line 155 of file GlPipe.h.
00156 {
00157 return mOpenWins;
00158 }
|
1.2.14 written by Dimitri van Heesch,
© 1997-2002