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

wrappedPrim.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////
00002 // 6/7/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 WRAPPED_PRIM_H__
00020 #define WRAPPED_PRIM_H__
00021 
00022 #include "rawPrim.h"
00023 #include "primsGL.h"
00024 
00025 namespace glift { 
00026 
00027 
00028 /////////////////////////////////////////////////////////////////////////
00029 ///
00030 ///  FactoryPrimGL - A factory class for PrimGL classes.
00031 ///  
00032 ///  - This class stores a PrimGL pointer for the derived classes.
00033 ///  - This class can only be constructed by a derived type and can never \n 
00034 ///    be default-constructed.
00035 ///  - Subclasses instantiate the base class and then does not have to handle the \n 
00036 ///    repetitive virtual functions that will be identical for all subclasses \n
00037 ///    that use only a single PrimGL object.
00038 ///    
00039 ///////////////////////////////////////////////////////////////////////
00040 
00041 class _export_ WrappedPrim : public SinglePrim
00042 {
00043 public:
00044    virtual ~WrappedPrim() { delete m_prim; }
00045 
00046    virtual const gutz::arrayo2f& vert()   const         { return m_prim->vert();}
00047    virtual const gutz::arrayo2f& texCoord() const               { return m_prim->texCoord();}
00048    virtual const gutz::arrayo2f& texCoord(int t) const { return m_prim->texCoord(t); }
00049    virtual int                                            numVerts() const              { return m_prim->numVerts(); }
00050    virtual bool                                   hasTexCoords() const  { return m_prim->hasTexCoords(); }
00051 
00052    virtual void bindTexCoords( const MultiPrimTexCoord* texCoords ) { m_prim->bindTexCoords(texCoords); }
00053    virtual void bindTexCoords( const MultiTexCoord* texCoords )  { m_prim->bindTexCoords(texCoords); }
00054    virtual void bindIndices(    const MultiPrimIndices* indices )        { m_prim->bindIndices(indices); }
00055    virtual void bindIndices(   const gutz::arrayw1ui* indices ) { m_prim->bindIndices(indices); }
00056    virtual void releaseIndices()                                                                         { m_prim->releaseIndices(); }
00057    virtual void releaseTexCoords()                                                                       { m_prim->releaseTexCoords(); }
00058 
00059 protected:
00060    WrappedPrim() : m_prim(NULL) {}
00061    WrappedPrim( PrimGL* prim ) : m_prim( prim ) {}      
00062    WrappedPrim( const WrappedPrim& rhs ) { m_prim = rhs.m_prim; }
00063    WrappedPrim& operator=(const WrappedPrim& rhs) {if(&rhs!=NULL){ m_prim=rhs.m_prim; } return *this;}
00064 
00065    virtual void drawDef() { m_prim->draw(); }
00066 
00067    virtual const gutz::vec3f& scale()     const { return m_prim->scale();    }
00068    void init( PrimGL* prim ) { m_prim = prim; }
00069 
00070 private:
00071    PrimGL*      m_prim;
00072 };
00073 
00074 } /// End of namespace glift
00075 
00076 #endif

Send questions, comments, and bug reports to:
jmk