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

shader.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////
00002 // 6/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 #if !defined(AFX_SHADER_H__FF91240C_EB1B_463E_8FC1_11FF08D6743C__INCLUDED_)
00020 #define AFX_SHADER_H__FF91240C_EB1B_463E_8FC1_11FF08D6743C__INCLUDED_
00021 
00022 #if _MSC_VER > 1000
00023 #pragma once
00024 #endif // _MSC_VER > 1000
00025 
00026 #include "stateGLI.h"
00027 #include "progShader.h"
00028 #include "../texture/texture.h"
00029 #include "../texture/subTex.h"
00030 #include "../texture/multiTex.h"
00031 #include "../texCoordGen/texCoordGen.h"
00032 #include "../texCoordGen/texCoordPerturb.h"
00033 
00034 #include <vector>
00035 
00036 namespace glift {
00037 
00038 
00039 /////////////////////////////////////////////////////////////////////////
00040 ///
00041 /// Shader.h: interface for the Shader class.
00042 ///
00043 /// - This class is designed to encapsulate all lighting, shading, texturing, etc
00044 ///   that is required for drawing a primitive.
00045 /// - The default constructor is for primitives drawn with no textures or shaders
00046 /// - This class should be subclassed to specify other required drawing state required
00047 ///   for a particular effect. The intent is to add calls to 'bindDef()' and 'release()'
00048 ///   in the subclasses.
00049 ///////////////////
00050 class _export_ Shader : public StateGLI, 
00051    public MultiTexCoordGen
00052 {
00053 public:
00054    Shader( GenState* genState );
00055    Shader( const VecStateP& genAttribs );
00056    Shader( Texture* tex, GenState* genState=NULL );
00057    Shader( Texture* tex, const VecStateP& genAttribs );
00058    Shader( Texture* tex, ProgShader* progShader, GenState* genState=NULL );
00059    Shader( Texture* tex, ProgShader* progShader, const VecStateP& genAttribs );
00060 
00061    Shader( const Shader& rhs );
00062    Shader& operator=( const Shader& rhs );
00063 
00064    virtual ~Shader();
00065 
00066    /// The 'MultiTexCrdGenerator' interface
00067    /// Generate appropriate texture coordinates, taking into account 
00068    /// multiTexturing, texCoordTransforms, and texture contants
00069    virtual MultiTexCoord* genTexCoords( const gutz::arrayw2f& rawTexCoord, const gutz::vec3f& primScale ) const;
00070 
00071    /// Accessors
00072    int  numTexUnits() const {return (m_texture ? m_texture->numTexUnits() : 0); }
00073 
00074 protected:
00075    virtual void bindDef();
00076    virtual void releaseDef();
00077 
00078 private:
00079    Texture*     m_texture;              /// Pointer to a texture object
00080    ProgShader*  m_progShader;   /// Pointer to programmable shader object.
00081    VecStateP    m_genAttribs;   /// Pointers to other attributes
00082 
00083    Shader();
00084    void initMembers( Texture* texturePtr, ProgShader* progShader, const VecStateP& genAttribs );
00085    void initMembers( const Shader& rhs );
00086    void checkTexture();
00087 };
00088 
00089 } /// End of namespace glift
00090 
00091 #endif /// !defined(AFX_SHADER_H__FF91240C_EB1B_463E_8FC1_11FF08D6743C__INCLUDED_)

Send questions, comments, and bug reports to:
jmk