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

progShader.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////
00002 // 6/13/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 PROGRAMMABLE_SHADER_H__
00020 #define PROGRAMMABLE_SHADER_H__
00021 
00022 #include "stateGLI.h"
00023 #include "../texCoordGen/texCoordGen.h"
00024 #include "../texCoordGen/texCoordPerturb.h"
00025 
00026 namespace glift {
00027 
00028 //////////////////////////////////////////////////////////////////////////
00029 ///
00030 /// ProgShader - A wrapper class for a programmable shader.
00031 /// 
00032 ///////////////////////////////////////////////////////////////////////
00033 /// Final. Not intended to be subclassed
00034 class _export_ ProgShader : 
00035    public StateGLI, 
00036    public MultiTexCoordGen
00037 {
00038 public:
00039    ProgShader( int numTexUnits, PixelShader*  pixShader,  TexCoordPerturb* texCoordPerturb=NULL );
00040    ProgShader( int numTexUnits, VertexShader* vertShader, TexCoordPerturb* texCoordPerturb=NULL );
00041    ProgShader( int numTexUnits, PixelShader*  pixShader,  VertexShader* vertShader, TexCoordPerturb* texCoordPerturb=NULL );
00042    ProgShader( const ProgShader& rhs );
00043    ProgShader& operator=( const ProgShader& rhs );
00044    ~ProgShader();
00045 
00046    void setPixelShader(   PixelShader* shader ) {m_pixelShader = shader;}
00047    void setVertexShader(  VertexShader* shader) {m_vertexShader = shader;}
00048 
00049    /// The 'MultiTexCrdGenerator' interface
00050    /// Generate appropriate texture coordinates, taking into account 
00051    /// multiTexturing, texCoordTransforms, and texture contants
00052    MultiTexCoord* genTexCoords( const gutz::arrayw2f& rawTexCoord, const gutz::vec3f& primScale ) const;
00053 
00054    //Constant Accessors
00055    int   numTexUnits() {return m_numTexUnits;}
00056 
00057 protected:
00058    virtual void bindDef();
00059    virtual void releaseDef();
00060 
00061 private:
00062    int                           m_numTexUnits;
00063    PixelShader*  m_pixelShader;
00064    VertexShader*         m_vertexShader;
00065    TexCoordPerturb* m_texCoordPerturb;
00066 
00067    ProgShader();
00068    void initMembers( const ProgShader& rhs );
00069    void initMembers( int numTexUnits, PixelShader*  pixShader, VertexShader* vertShader, 
00070       TexCoordPerturb* texCoordPerturb );
00071 };
00072 
00073 typedef gutz::SmartPtr<ProgShader> ProgShaderSP;
00074 
00075 //////////////////////////////////////////////////////////////////////////////////
00076 /// Factory functions <progShaderFactory.cpp>
00077 ///  these allow you to specify an alternate error stream, if you don't set it
00078 ///  the default will be used.
00079 //////////////////////////////////////////////////////////////////////////////////
00080 
00081 ProgShaderSP getProgShaderFromFile(const char *fileName, std::ostream *es = 0);
00082 ProgShaderSP getProgShaderFromText(const char *progText, std::ostream *es = 0);
00083 
00084 
00085 } /// End of namespace glift
00086 
00087 #endif

Send questions, comments, and bug reports to:
jmk