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

multiTexState.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////
00002 // 9/8/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_MULTI_TEXSTATE_H_
00020 #define GLIFT_MULTI_TEXSTATE_H_
00021 
00022 #include "texState.h"
00023 #include <vector>
00024 
00025 namespace glift {
00026 
00027 /// Typedefs
00028 class MultiTexOState;
00029 class MultiTexUState;
00030 typedef std::vector<MultiTexOState>             VecMultiTexOState;
00031 typedef std::vector<MultiTexOState*>    VecMultiTexOStateP;
00032 typedef std::vector<MultiTexUState>             VecMultiTexUState;
00033 typedef std::vector<MultiTexUState*>    VecMultiTexUStateP;
00034 
00035 
00036 //////////////////////////////////////////////////////////////////////////
00037 ///
00038 /// MultiTexOState - A container class for multiple TexObjState objects
00039 ///                               - This is a "composite" class of 'TexObjState'
00040 ///                               - An instance of this class is passed to instantiate a 
00041 ///                                 glift texture.
00042 ///
00043 /// MultiTexUState - A container class for multiple TexUnitState objects
00044 ///                               - This is a "composite" class of 'TexUnitState'
00045 ///                               - Instances of this class are combined into a vector
00046 //                                      that is passed to instantiate a 'MultiTexture'. 
00047 //                                - Each 'MultiTexUState' object sets the state for a
00048 //                                      single texture unit.
00049 ///
00050 /// MultiTexOState - Class that enforces use of TexObjState ptrs
00051 /////////////////////////////////////////////////////////////////////////
00052 class _export_ MultiTexOState : public TexObjState
00053 {
00054 public:
00055    MultiTexOState( const VecTexOStateP& state = VecTexOStateP() );
00056 
00057    /// TexState interface
00058    virtual void bind( GLenum texType ) const;
00059    virtual void release() const;
00060 
00061    /// Set Methods
00062    TexObjState*&                                        operator[] (int i) { return m_state[i]; }
00063    friend inline MultiTexOState& operator<< (MultiTexOState& rhs, TexObjState* state);
00064    friend inline MultiTexOState& operator<< (MultiTexOState& rhs, const TexObjState* state);
00065 
00066    /// Accessors
00067    int  size() const  {return m_state.size();}
00068    bool empty() const {return m_state.empty();}
00069 
00070 private:
00071    VecTexOStateP        m_state;
00072 };
00073 
00074 /////////////////////////////////////////////////////////////////////////
00075 /// MultiTexUState - Class that enforces use of TexUnitState ptrs
00076 /////////////////////////////////////////////////////////////////////////
00077 class _export_ MultiTexUState : public TexUnitState
00078 {
00079 public:
00080    MultiTexUState( const VecTexUStateP& state = VecTexUStateP() );
00081    virtual ~MultiTexUState() {}
00082 
00083    /// TexState interface
00084    virtual void bind( GLenum texType ) const;
00085    virtual void release() const;
00086 
00087    /// Set Methods
00088    TexUnitState*&                                        operator[] (int i) { return m_state[i]; }
00089    friend inline MultiTexUState& operator<< (MultiTexUState& rhs, TexUnitState* state);
00090    friend inline MultiTexUState& operator<< (MultiTexUState& rhs, const TexUnitState* state);
00091 
00092    /// Accessors
00093    int  size() const  {return m_state.size();}
00094    bool empty() const {return m_state.empty();}
00095 
00096 private:
00097    VecTexUStateP        m_state;
00098 };
00099 
00100 inline MultiTexOState& operator<<( MultiTexOState& rhs, TexObjState* state )
00101 {
00102    rhs.m_state.push_back(state);
00103    return rhs;
00104 }
00105 
00106 inline MultiTexOState& operator<<( MultiTexOState& rhs, const TexObjState* state )
00107 {
00108    rhs.m_state.push_back((TexObjState*)state);
00109    return rhs;
00110 }
00111 
00112 inline MultiTexUState& operator<<( MultiTexUState& rhs, TexUnitState* state )
00113 {
00114    rhs.m_state.push_back(state);
00115    return rhs;
00116 }
00117 
00118 inline MultiTexUState& operator<<( MultiTexUState& rhs, const TexUnitState* state )
00119 {
00120    rhs.m_state.push_back((TexUnitState*)state);
00121    return rhs;
00122 }
00123 
00124 } /// End of namespace glift
00125 
00126 #endif
00127 

Send questions, comments, and bug reports to:
jmk