Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

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-2003 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: GlPipe.h,v $
00027  * Date modified: $Date: 2003/12/31 23:25:42 $
00028  * Version:       $Revision: 1.41 $
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/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; }     // Set the control loop exit flag
00104 
00105 public:     // --------- Triggering functions ------ //
00111    void triggerRender();
00112 
00118    void completeRender();
00119 
00125    void triggerSwap();
00126 
00132    void completeSwap();
00133 
00134 public: // --- Window Management ----- //
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

Generated on Sun May 2 15:10:17 2004 for VR Juggler by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002