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

GlProcApp.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: GlProcApp.h,v $
00027  * Date modified: $Date: 2003/10/06 22:17:13 $
00028  * Version:       $Revision: 1.1 $
00029  * -----------------------------------------------------------------
00030  *
00031  *************** <auto-copyright.pl END do not edit this line> ***************/
00032 
00033 #ifndef _VRJ_GL_PROC_APP_H_
00034 #define _VRJ_GL_PROC_APP_H_
00035 
00036 #include <vrj/Draw/OGL/GlApp.h>
00037 #include <boost/function.hpp>     // Could use function pointers, but this is a little easier to read
00038 
00039 using namespace vrj;    // Use vrj namespace for simplicity
00040 
00041 namespace vrj
00042 {
00043 
00045 class GlProcAppWrapper : public vrj::GlApp
00046 {
00047 public:
00048    typedef boost::function0<void> callback_t;      
00050 public:
00051    GlProcAppWrapper()      
00052    {;}
00053    virtual ~GlProcAppWrapper()
00054    {;}
00055 
00056 public:  //** Getters and setters for the callback methods */
00057    void setDrawMethod(callback_t f)
00058    { mDrawMethod = f; }
00059    void setContextInitMethod(callback_t f)
00060    { mContextInit = f; }
00061    void setBufferPredrawMethod(callback_t f)
00062    { mBufferPredrawMethod = f; }
00063    void setPreFrameMethod(callback_t f)
00064    { mPreframeMethod = f; }
00065    void setPostFrameMethod(callback_t f)
00066    { mPostframeMethod = f; }
00067    void setIntraFrameMethod(callback_t f)
00068    { mIntraframeMethod = f; }
00069 
00070 public:
00071    virtual void draw()
00072    {
00073       if (!mDrawMethod.empty())
00074       {  mDrawMethod(); }
00075    }
00076 
00077    virtual void contextInit()
00078    {
00079       if (!mContextInit.empty())
00080       {  mContextInit(); }
00081    }
00082 
00083    virtual void bufferPreDraw()
00084    {
00085       if (!mBufferPredrawMethod.empty())
00086       {  mBufferPredrawMethod(); }
00087    }
00088 
00089    virtual void preFrame()
00090    {
00091       if (!mPreframeMethod.empty())
00092       {  mPreframeMethod(); }
00093    }
00094 
00095    virtual void intraFrame()
00096    {
00097       if (!mIntraframeMethod.empty())
00098       {  mIntraframeMethod(); }
00099    }
00100 
00101    virtual void postFrame()
00102    {
00103       if (!mPostframeMethod.empty())
00104       {  mPostframeMethod(); }
00105    }
00106 
00107 protected:
00108    callback_t  mDrawMethod;
00109    callback_t  mContextInit;
00110    callback_t  mPreframeMethod;
00111    callback_t  mPostframeMethod;
00112    callback_t  mIntraframeMethod;
00113    callback_t  mBufferPredrawMethod;
00114 };
00115 
00116 }
00117 
00119 namespace
00120 {
00121    vrj::GlProcAppWrapper proc_app_singleton;    
00122 }
00123 
00124 namespace vrj
00125 {
00126    void VRJSetGLDrawMethod(vrj::GlProcAppWrapper::callback_t m)
00127    {
00128       proc_app_singleton.setDrawMethod(m);
00129    }
00130 
00131    void VRJSetGLContextInitMethod(vrj::GlProcAppWrapper::callback_t m)
00132    { 
00133       proc_app_singleton.setContextInitMethod(m);
00134    }
00135    
00136    void VRJSetBufferPredrawMethod(vrj::GlProcAppWrapper::callback_t m)
00137    { 
00138       proc_app_singleton.setBufferPredrawMethod(m);
00139    }
00140 
00141    void VRJSetPreFrameMethod(vrj::GlProcAppWrapper::callback_t m)
00142    {
00143       proc_app_singleton.setPreFrameMethod(m);
00144    }
00145 
00146    void VRJSetIntraFrameMethod(vrj::GlProcAppWrapper::callback_t m)
00147    {
00148       proc_app_singleton.setIntraFrameMethod(m);
00149    }
00150    
00151    void VRJSetPostFrameMethod(vrj::GlProcAppWrapper::callback_t m)
00152    {
00153       proc_app_singleton.setPostFrameMethod(m);
00154    }
00155 
00156    void VRJConfigure(int argc, char* argv[])
00157    {
00158        // Allocate the kernel object and the application object
00159       Kernel* kernel = Kernel::instance();           // Get the kernel
00160       
00161       // IF no args passed to the program
00162       //    Display usage information and exit
00163       if (argc <= 1)
00164       {
00165          std::cout << "\n\n";
00166          std::cout << "Usage: " << argv[0] << " vjconfigfile[0] vjconfigfile[1] ... vjconfigfile[n]" << std::endl;
00167          exit(1);
00168       }
00169 
00170       // Load any config files specified on the command line
00171       for( int i = 1; i < argc; ++i )
00172       {
00173          kernel->loadConfigFile(argv[i]);
00174       }
00175    }
00176 
00178    void VRJProcRunSystem()
00179    {
00180        // Allocate the kernel object and the application object
00181       Kernel* kernel = Kernel::instance();           // Get the kernel
00182       
00183       // Start the kernel running
00184       kernel->start();
00185 
00186       // Give the kernel an application to execute
00187       kernel->setApplication(&proc_app_singleton);
00188 
00189       // Keep thread alive and waiting
00190       kernel->waitForKernelStop();
00191    }   
00192 }
00193 
00194 
00195 #endif
00196 

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