arbeit
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

pbuffGlift.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////////////
00002 // 10/02/02     Aaron Lefohn    Scientific Computing and Imaging Institute      
00003 // School of Computing                  University of Utah
00004 //
00005 //  This library is free software; you can redistribute it and/or
00006 //  modify it under the terms of the GNU Lesser General Public
00007 //  License as published by the Free Software Foundation; either
00008 //  version 2.1 of the License, or (at your option) any later version.
00009 //
00010 //  This library is distributed in the hope that it will be useful,
00011 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 //  Lesser General Public License for more details.
00014 //
00015 //  You should have received a copy of the GNU Lesser General Public
00016 //  License along with this library; if not, write to the Free Software
00017 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 #ifndef PBUFF_GLIFT_H
00020 #define PBUFF_GLIFT_H
00021 
00022 #include "stateGLI.h"
00023 #include "../util/command.h"
00024 #include <GL/pbuffer.h>
00025 #include <mathGutz.h>
00026 #include <vector>
00027 
00028 namespace glift {
00029 
00030 // Typedefs
00031 class PBuffGlift;
00032 typedef std::vector<PBuffGlift>  VecPbuff;
00033 typedef std::vector<PBuffGlift*> VecPbuffP;
00034 
00035 /////////////////////////////////
00036 /// PBuffGlift
00037 /////////////////////////////////
00038 
00039 //////////////////////////////////////////////////////////////////////////////////
00040 //
00041 /// PBuffGlift - An adapter class to turn a PBuffer into a StateGLI object
00042 ///                        - Adds the ability to initialize the render context via a 
00043 ///                              member or non-member callback, 'initCB'
00044 //
00045 ///////////////////////////////////////////////////////////////////////////////
00046 class PBuffGlift : public StateGLI
00047 {
00048 public:
00049    PBuffGlift( PBuffer* pbuff );
00050    PBuffGlift( int xDim, int yDim, uint mode, PBuffRenCTX renderCTX=NULL );
00051 
00052    // Initialize renderCTX by calling 'initCB'. Can be a member or non-member fcn callback.
00053    PBuffGlift( int xDim, int yDim, uint mode, VoidFuncPtr initCB, PBuffRenCTX renderCTX=NULL );
00054    PBuffGlift( int xDim, int yDim, uint mode, Command*   initCB, PBuffRenCTX renderCTX=NULL );
00055 
00056    // Using default copy constructor and assignment operator
00057    virtual ~PBuffGlift();
00058 
00059    // Enable/Disable pbuffer as a draw target
00060    // Disable will restore previous state if enable(true) was called.
00061    virtual void enable(bool saveState=false) {m_pbuff->enable(saveState);}
00062    void disable()                                         {m_pbuff->disable();           }
00063 
00064    // Set WGL_FRONT_LEFT_ARB,   WGL_AUX0_ARB, etc.
00065    void setSurface( GLenum surface )              {m_pbuff->setSurface(surface);}
00066 
00067    // Set mip level that is rendered to. Default = 0
00068    void setMipLevel( int level )                          {m_pbuff->setMipLevel(level);}
00069 
00070    // Set       WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB, etc. : Default = POSITIVE_X
00071    void setCubeFace( GLenum cubeFace )            {m_pbuff->setCubeFace(cubeFace);}
00072 
00073    // Accessors
00074    inline PBuffer* pbuff() const;
00075    inline gutz::vec2i   dimen() const;                                           
00076    inline void                  dimen( int& xDim, int& yDim ) const;
00077    inline unsigned int  mode() const;
00078    inline int                   numSurfaces() const;
00079    inline PBuffRenCTX   renderCTX() const;
00080 
00081    // Convenience mode accessors
00082    bool hasRendToTex()  const {return m_pbuff->hasRendToTex();}
00083    bool hasMipMap()     const {return m_pbuff->hasMipMap();      }
00084    bool hasCube()               const {return m_pbuff->hasCube();        }
00085 
00086 protected:
00087    virtual void bindDef()               { m_pbuff->bind(); }
00088    virtual void releaseDef()    { m_pbuff->release(); }
00089 
00090 private:
00091    PBuffer* m_pbuff;
00092    Command* m_initCB;
00093    bool  m_deletePBuff;
00094 
00095    PBuffGlift();        // Disallow default construction
00096    void init(); // Initialize RenCTX via 'm_initCB'
00097 };
00098 
00099 // Inline accessors
00100 inline PBuffer* PBuffGlift::pbuff() const
00101 {
00102    return m_pbuff;
00103 }
00104 
00105 inline gutz::vec2i PBuffGlift::dimen() const
00106 {
00107    int x,y; 
00108    m_pbuff->dimen(x,y); 
00109    return gutz::vec2i(x,y);
00110 }
00111 
00112 inline void PBuffGlift::dimen(int& x, int& y) const
00113 {
00114    m_pbuff->dimen(x,y);
00115 }
00116 
00117 inline unsigned int PBuffGlift::mode() const
00118 {
00119    return m_pbuff->mode();
00120 }
00121 
00122 inline int PBuffGlift::numSurfaces() const
00123 {
00124    return m_pbuff->numSurfaces();
00125 }
00126 
00127 inline PBuffRenCTX PBuffGlift::renderCTX() const
00128 {
00129    return m_pbuff->renderCTX();
00130 }
00131 
00132 
00133 } // End namespace
00134 
00135 #endif
00136 
00137 

Send questions, comments, and bug reports to:
jmk