GlPipe.h

Go to the documentation of this file.
00001 /*************** <auto-copyright.pl BEGIN do not edit this line> **************
00002  *
00003  * VR Juggler is (C) Copyright 1998-2005 by Iowa State University
00004  *
00005  * Original Authors:
00006  *   Allen Bierbaum, Christopher Just,
00007  *   Patrick Hartling, Kevin Meinert,
00008  *   Carolina Cruz-Neira, Albert Baker
00009  *
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Library General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2 of the License, or (at your option) any later version.
00014  *
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Library General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU Library General Public
00021  * License along with this library; if not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00023  * Boston, MA 02111-1307, USA.
00024  *
00025  * -----------------------------------------------------------------
00026  * File:          $RCSfile$
00027  * Date modified: $Date: 2006-11-07 18:59:25 -0600 (Tue, 07 Nov 2006) $
00028  * Version:       $Revision: 19418 $
00029  * -----------------------------------------------------------------
00030  *
00031  *************** <auto-copyright.pl END do not edit this line> ***************/
00032 
00033 #ifndef _VRJ_GL_PIPE_H_
00034 #define _VRJ_GL_PIPE_H_
00035 
00036 #include <vrj/Draw/OGL/Config.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 namespace vrj
00045 {
00046    class GlDrawManager;
00047 
00057 class VJ_OGL_CLASS_API GlPipe
00058 {
00059 public:
00072    GlPipe(size_t num, GlDrawManager* glMgr, vpr::Mutex* drawMgrWinLock)
00073       : mControlFunctor(NULL)
00074       , mActiveThread(NULL)
00075       , mPipeNum(num)
00076       , mControlExit(0)
00077       , mGlDrawManager(glMgr)
00078       , mDrawMgrWinLock(drawMgrWinLock)
00079       , mRenderTriggerSema(0)
00080       , mRenderCompleteSema(0)
00081       , mSwapTriggerSema(0)
00082       , mSwapCompleteSema(0)
00083    {
00084       mThreadRunning = false;
00085    }
00086 
00087    ~GlPipe();
00088 
00098    int start();
00099 
00105    void controlLoop(void* nullParam);
00106 
00111    void stop();
00112 
00113 public:     // --------- Triggering functions ------ //
00119    void triggerRender();
00120 
00126    void completeRender();
00127 
00133    void triggerSwap();
00134 
00140    void completeSwap();
00141 
00142 public: // --- Window Management ----- //
00143 
00148    void addWindow(GlWindow* win);
00149 
00154    void removeWindow(GlWindow* win);
00155 
00157    int hasWindows()
00158    {
00159       return ( (mNewWins.size() > 0) || (mOpenWins.size() > 0));
00160    }
00161 
00163    const std::vector<GlWindow*>& getOpenWindows()
00164    {
00165       return mOpenWins;
00166    }
00167 
00168 private:
00174    void checkForNewWindows();
00175 
00181    void checkForWindowsToClose();
00182 
00187    void renderWindow(GlWindow* win);
00188 
00190    void swapWindowBuffers(GlWindow* win);
00191 
00196    void finishWindowSetup(GlWindow* win);
00197 
00198    GlPipe(const GlPipe&) {;}
00199    void operator=(const GlPipe&) {;}
00200 
00201 private:
00202    vpr::ThreadMemberFunctor<GlPipe>* mControlFunctor;
00203    vpr::Thread*   mActiveThread;    
00204    bool           mThreadRunning;   
00206    size_t         mPipeNum;         
00208    std::vector<GlWindow*>  mNewWins;         
00209    vpr::Mutex              mNewWinLock;      
00211    std::vector<GlWindow*>  mOpenWins;        
00212    vpr::Mutex              mOpenWinLock;     
00214    std::vector<GlWindow*>  mClosingWins;     
00215    vpr::Mutex              mClosingWinLock;  
00217    int                     mControlExit;     
00219    GlDrawManager*          mGlDrawManager;   
00221    vpr::Mutex*             mDrawMgrWinLock;  
00224    vpr::Semaphore    mRenderTriggerSema;  
00225    vpr::Semaphore    mRenderCompleteSema; 
00226    vpr::Semaphore    mSwapTriggerSema;    
00227    vpr::Semaphore    mSwapCompleteSema;   
00228 };
00229 
00230 }
00231 
00232 #endif

Generated on Thu Jan 4 10:56:51 2007 for VR Juggler by  doxygen 1.5.1