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

subTex.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////
00002 // 8/10/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_SUB_TEXTURE_H_
00020 #define GLIFT_SUB_TEXTURE_H_
00021 
00022 #include "singleTex.h"
00023 #include "../state/subPBuff.h"
00024 #include <arrayGutz.h>
00025 
00026 namespace glift {
00027 
00028 //////////////////////////////////////////////////////////////////////////
00029 ///
00030 /// SubTex - A sub-region of a larger texture that is treated
00031 ///                      as its own Glift texture.
00032 ///                - SubTex can be used to make "virtual textures", where
00033 ///                      multiple SubTextures share the same memory space.
00034 /// 
00035 ///////////////////////////////////////////////////////////////////////
00036 
00037 class _export_ SubTex : public SingleTex
00038 {
00039 public:
00040    SubTex( SingleTex* tex, GLenum channel=GL_RGBA);
00041    SubTex( const MultiTexOState& texState, SubPBuff* subPBuff, GLenum channel=GL_RGBA);
00042    SubTex( SingleTex* tex, int origin, int dimen, GLenum channel=GL_RGBA );
00043    SubTex( SingleTex* tex, const gutz::vec2i& origin, const gutz::vec2i& dimen, GLenum channel=GL_RGBA );
00044    SubTex( SingleTex* tex, const gutz::vec3i& origin, const gutz::vec3i& dimen, GLenum channel=GL_RGBA );
00045    /// Default copy constructor and assignment operator
00046    ~SubTex();
00047 
00048    /// Accessors
00049    SingleTex*                   tex() const             {return m_tex;}
00050    const gutz::vec3i&   origin() const  {return m_origin;}
00051    virtual gutz::vec3i  dimen()  const  {return m_dimen; }
00052    GLenum                               channel() const {return m_channel;}
00053 
00054    virtual PBuffGlift*  pbuff() const   {return m_tex->pbuff();  }/// Ptr to the pbuffer
00055    virtual GLenum                       texType() const {return m_tex->texType();}
00056    virtual GLuint                       texNum() const  {return m_tex->texNum(); }
00057    virtual bool                 tryToBindPbuff() const {return m_tex->tryToBindPbuff();}        
00058    inline virtual void          copyToTex( int mipLevel, const gutz::vec3i& texOrig, 
00059       const gutz::vec2i& screenOrig, 
00060       const gutz::vec2i& copySize   );
00061 
00062    // Read texture data back from the card
00063    virtual void                 getDataub( GLenum format, int mipLevel, gutz::arraybub& data ); 
00064    virtual void                 getDataf(  GLenum format, int mipLevel, gutz::arraybf&  data );
00065 
00066    /// Set Funcs
00067    virtual void setTexData( TexData* texData, int mipLevel=0, bool setTexSize=true )    { m_tex->setTexData(texData, mipLevel, setTexSize); }
00068    virtual void setTexState( TexObjState* texState )                    { m_tex->setTexState(texState); }
00069    virtual void setTexState( const MultiTexOState& texState )   { m_tex->setTexState(texState); }
00070    virtual void tryToBindPbuff( bool tryToUsePbuff )                    { m_tex->tryToBindPbuff(tryToUsePbuff); }
00071 
00072    /// Texture-Coordinate Utilities
00073    void adjustTexCoord( gutz::arrayw2f& texCoord ) {}
00074 
00075 protected:
00076    /// The StateGLI interface
00077    virtual void bindDef(); 
00078    virtual void releaseDef(); 
00079 
00080 private:
00081    SingleTex*   m_tex;
00082    bool         m_createdTex;
00083    gutz::vec3i  m_origin;
00084    gutz::vec3i  m_dimen;
00085    gutz::vec3f m_scale;
00086    gutz::vec3f m_bias;
00087    GLenum               m_channel;
00088 
00089    SubTex();
00090    void initMembers( SingleTex* tex, const gutz::vec3i& origin,
00091       const gutz::vec3i& dimen, GLenum channel );
00092 };
00093 
00094 inline void SubTex::copyToTex(  int mipLevel, const gutz::vec3i& texOrig, const gutz::vec2i& screenOrig, 
00095                               const gutz::vec2i& copySize   ) 
00096 { 
00097    m_tex->copyToTex(mipLevel, texOrig, screenOrig, copySize); 
00098 }
00099 
00100 
00101 } /// End of namespace glift
00102 
00103 #endif
00104 

Send questions, comments, and bug reports to:
jmk