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

shadedPrim.h

Go to the documentation of this file.
00001 //////////////////////////////////////////////////////////////////////
00002 // 6/12/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 #ifndef GLIFT_SHADED_PRIM_H__
00019 #define GLIFT_SHADED_PRIM_H__
00020 
00021 #include "drawableGLI.h"
00022 #include "rawPrim.h"
00023 #include "../state/shader.h"
00024 #include <mathGutz.h>
00025 #include <arrayGutz.h>
00026 
00027 namespace glift {
00028 
00029 /////////////////////////////////////////////////////////////////////////
00030 ///
00031 ///  ShadedPrim - The class that binds a shader and primitive together
00032 ///  
00033 ///  - If 'prim' is a 'RawPrim':
00034 ///  - Texture scale/bias and texCoordConsts get applied here.
00035 ///  - Multitexturing coordinates get created based on the number of \n
00036 ///       textures defined in the shader's texture scale/bias information
00037 ///  - If 'prim' is a 'ShadedPrim'
00038 ///  - Simply binds the 'shader' around the 'prim' w/out attempting \n
00039 ///       to generate multi- or perturbed texture coordinates.
00040 /// 
00041 /// ShadedPrim
00042 ////////////////////////////////
00043 class _export_ ShadedPrim : public DrawableGLI
00044 {
00045 public: 
00046    ShadedPrim( DrawableGLI* prim, Shader* shader );
00047 
00048    ShadedPrim( const ShadedPrim& rhs);
00049    ShadedPrim& operator=(const ShadedPrim& rhs);
00050    virtual ~ShadedPrim();
00051 
00052    /// Set a new 'm_prim' and 'm_rawPrim' if 'prim' is non-NULL
00053    /// - Note: The texture coords are NOT altered...just the primitive.
00054    /// - VERY DANGEROUS. Designed to be fast, not safe
00055    void setPrim( DrawableGLI*  prim );
00056 
00057    /// Set the texture coords used if 'texCoordsPtr' is non-NULL
00058    /// - Note: No checks are done to ensure compatibility between vertices, texCoords, shaders, etc.
00059    /// - DANGEROUS. Designed to be fast, not safe
00060    void setTexCoordPtr( MultiPrimTexCoord* texCoordsPtr );
00061 
00062 protected:
00063    virtual void drawDef();
00064 
00065 private:
00066    DrawableGLI*         m_prim;                 /// The primitive
00067    RawPrim*                     m_rawPrim;              /// Pointer to m_prim if a 'RawPrim' was passed in. Otherwise it is NULL.
00068    Shader*                      m_shader;               /// The shader
00069    MultiPrimTexCoord*   m_texCoordsPtr; /// The generated multi- and/or perturbed texture coordinates
00070    GLuint                               m_dispList;
00071 
00072    ShadedPrim();
00073    void initMembers( DrawableGLI* prim, RawPrim* rawPrim, Shader* shader, MultiPrimTexCoord* texCoordsPtr );
00074    void initMembers( const ShadedPrim& rhs );
00075 };
00076 
00077 }
00078 
00079 #endif
00080 

Send questions, comments, and bug reports to:
jmk