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

texNd.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////
00002 // 9/6/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 GLIFT_TEXTURE_ND_H_
00020 #define GLIFT_TEXTURE_ND_H_
00021 
00022 #include "singleTex.h"
00023 
00024 // The OpenGL object oriented framework. "Lifting" your OpenGL code to new levels.
00025 namespace glift {
00026 
00027 /////////////////////////////////////////////////////////////////////////
00028 ///
00029 /// Tex1D, Tex2D, Tex3D, TexCube
00030 ///   - These are the publicly constructed texture objects
00031 ///   - 'texState' is vector of TexState pointers that initialize the texture object's state
00032 ///   - 'pbuff' is NULL or a pbuffer pointer that is bound with this texture unit
00033 ///   - Texture memory is initialized by passing 'setTexData(...)' functions a 'TexData' object
00034 ///   - 'copyToTex*D(...)' copies data from the framebuffer to the texture object
00035 ///   - See 'SingleTex' header for rest of public interface
00036 ////////////////////////////
00037 ///
00038 ///     Tex1D   - 2D texture class
00039 ///     Tex2D   - 2D texture class
00040 ///     Tex3D   - 3D texture class
00041 ///     TexCube - Cube map texture class
00042 ///                     
00043 /// Tex1D - 1D Textures
00044 /////////////////////////////////////////
00045 class _export_ Tex1D : public CoreTex
00046 {
00047 public:
00048    Tex1D( const MultiTexOState&  texState, 
00049       PBuffGlift            *pbuff=NULL );
00050 
00051    Tex1D( const MultiTexOState&  texState, 
00052       TexData               *texData, 
00053       PBuffGlift            *pbuff=NULL );
00054 
00055    /// Copy data from framebuffer to this texture
00056    virtual void copyToTex( int mipLevel,
00057       const gutz::vec3i& texOrig, 
00058       const gutz::vec2i& screenOrig, 
00059       const gutz::vec2i& copySize   );
00060 private:
00061    Tex1D();
00062 };
00063 
00064 /////////////////////////////////////////
00065 /// Tex2D - 2D Textures
00066 /////////////////////////////////////////
00067 class _export_ Tex2D : public CoreTex
00068 {
00069 public:
00070    Tex2D( const MultiTexOState&  texState, 
00071       PBuffGlift            *pbuff=NULL );
00072 
00073    Tex2D( const MultiTexOState&  texState, 
00074       TexData               *texData, 
00075       PBuffGlift            *pbuff=NULL );
00076 
00077    /// Copy data from framebuffer to this texture
00078    void copyToTex2D();          /// Fill entire 2D texture from framebuffer             
00079    virtual void copyToTex( int mipLevel,
00080       const gutz::vec3i& texOrig, 
00081       const gutz::vec2i& screenOrig, 
00082       const gutz::vec2i& copySize   );
00083 
00084 private:
00085    Tex2D(); /// Dissallow default construction
00086 };
00087 
00088 /////////////////////////////////////////
00089 /// TexRect - Rectangular Textures (non-power-of-two)
00090 /////////////////////////////////////////
00091 class _export_ TexRect : public CoreTex
00092 {
00093 public:
00094    TexRect( const MultiTexOState&  texState, 
00095       PBuffGlift            *pbuff=NULL );
00096 
00097    TexRect( const MultiTexOState&  texState, 
00098       TexData               *texData, 
00099       PBuffGlift            *pbuff=NULL );
00100 
00101    /// Copy data from framebuffer to this texture
00102    void copyToTex2D();          /// Fill entire 2D texture from framebuffer             
00103    virtual void copyToTex( int mipLevel,
00104       const gutz::vec3i& texOrig, 
00105       const gutz::vec2i& screenOrig, 
00106       const gutz::vec2i& copySize   );
00107 
00108 private:
00109    TexRect(); /// Dissallow default construction
00110    GLenum getTarget();
00111 };
00112 
00113 /////////////////////////////////////////
00114 /// Tex3D - 3D Textures
00115 /////////////////////////////////////////
00116 class _export_ Tex3D : public CoreTex
00117 {
00118 public:
00119    Tex3D( const MultiTexOState& texState, 
00120       TexData*              texData );
00121 
00122    /// Copy data from framebuffer to this texture
00123    virtual void copyToTex( int mipLevel,
00124       const gutz::vec3i& texOrig, 
00125       const gutz::vec2i& screenOrig, 
00126       const gutz::vec2i& copySize   );
00127 
00128 private:
00129    Tex3D(); /// Dissallow default construction
00130 };
00131 
00132 /////////////////////////////////////////
00133 /// TexCube - CubeMap Textures
00134 /////////////////////////////////////////
00135 class _export_ TexCube : public CoreTex
00136 {
00137 public:
00138    /// Constructors - If 'texData' is given, it must have size 6. The data is mapped in order:
00139    ///                            PX, NX, PY, NY, PZ, NZ (in positions 0..5)
00140    TexCube( const MultiTexOState& texState, 
00141       const VecTexDataP&    texData=VecTexDataP() );
00142 
00143    TexCube( const MultiTexOState&  texState,
00144       PBuffGlift            *pbPX, 
00145       PBuffGlift            *pbNX, 
00146       PBuffGlift            *pbPY, 
00147       PBuffGlift            *pbNY, 
00148       PBuffGlift            *pbPZ, 
00149       PBuffGlift            *pbNZ,
00150       const VecTexDataP& texData=VecTexDataP() );
00151 
00152    /// CubeMap set function. 
00153    void setTexData( const VecTexDataP& dataVec ) { initData(dataVec); }
00154    void setTexData( GLenum cubeFace, TexData* texData, int mipLevel=0, bool setTexSize=true );
00155 
00156    /// Copy data from framebuffer to this texture
00157    void          setCopyCubeFace( GLenum cubeFace );            /// Set the target for a glCopyTexImage(...)
00158    void          copyToTex( GLenum cubeFace );                          /// Fill entire cubeFace with entire framebuffer contents
00159    virtual void copyToTex( int mipLevel,
00160       const gutz::vec3i& texOrig, 
00161       const gutz::vec2i& screenOrig, 
00162       const gutz::vec2i& copySize   );
00163 
00164 protected:
00165    virtual void bindDef();
00166    virtual void releaseDef();
00167 
00168 private:
00169    VecPbuffP    m_pbuff;         /// Vector of pbuffer pointers. One for each cube face
00170    GLenum               m_writeFace; /// Current cube face to which copyToTex(..) will write
00171 
00172    TexCube(); /// Dissallow default construction
00173 
00174    void checkCubeFace( GLenum cubeFace ); /// Ensure that cubeFace is valid
00175    void initPbuffVec( PBuffGlift* pbPX, PBuffGlift* pbNX,  PBuffGlift* pbPY, PBuffGlift* pbNY, PBuffGlift* pbPZ, PBuffGlift* pbNZ );
00176    void initData(  const VecTexDataP& texData );
00177 };
00178 
00179 } /// End of glift namespace
00180 #endif
00181 

Send questions, comments, and bug reports to:
jmk