Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/RenderSystems/GL/src/GLSL/include/OgreGLSLLinkProgram.h @ 3

Last change on this file since 3 was 3, checked in by anonymous, 17 years ago

=update

File size: 5.0 KB
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4    (Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2006 Torus Knot Software Ltd
8Also see acknowledgements in Readme.html
9
10This program is free software you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23
24You may alternatively use this source under the terms of a specific version of
25the OGRE Unrestricted License provided you have obtained such a license from
26Torus Knot Software Ltd.
27-----------------------------------------------------------------------------
28*/
29#ifndef __GLSLLinkProgram_H__
30#define __GLSLLinkProgram_H__
31
32#include "OgreGLPrerequisites.h"
33#include "OgreGpuProgram.h"
34#include "OgreHardwareVertexBuffer.h"
35
36namespace Ogre {
37        /// structure used to keep track of named uniforms in the linked program object
38        struct GLUniformReference
39        {
40                /// GL location handle
41                GLint  mLocation;
42                /// Which type of program params will this value come from?
43                GpuProgramType mSourceProgType;
44                /// The constant definition it relates to
45                const GpuConstantDefinition* mConstantDef;
46        };
47
48        typedef std::vector<GLUniformReference> GLUniformReferenceList;
49        typedef GLUniformReferenceList::iterator GLUniformReferenceIterator;
50
51        /** C++ encapsulation of GLSL Program Object
52
53        */
54
55        class _OgrePrivate GLSLLinkProgram
56        {
57        private:
58                /// container of uniform references that are active in the program object
59                GLUniformReferenceList mGLUniformReferences;
60
61                /// Linked vertex program
62                GLSLGpuProgram* mVertexProgram;
63                /// Linked fragment program
64                GLSLGpuProgram* mFragmentProgram;
65
66                /// flag to indicate that uniform references have already been built
67                bool            mUniformRefsBuilt;
68                /// GL handle for the program object
69                GLhandleARB mGLHandle;
70                /// flag indicating that the program object has been successfully linked
71                GLint           mLinked;
72                // Custom attribute bindings
73                /// 'tangent' attribute
74                GLuint mTangentAttrib;
75                /// 'binormal' attribute
76                GLuint mBinormalAttrib;
77                /// 'blendIndices' attribute
78                GLuint mBlendIndicesAttrib;
79                /// 'blendWeights' attribute
80                GLuint mBlendWeightsAttrib;
81        /// flag indicating skeletal animation is being performed
82        bool mSkeletalAnimation;
83
84                /// build uniform references from active named uniforms
85                void buildGLUniformReferences(void);
86                /// extract attributes
87                void extractAttributes(void);
88
89               
90
91        public:
92                /// constructor should only be used by GLSLLinkProgramManager
93                GLSLLinkProgram(GLSLGpuProgram* vertexProgram, GLSLGpuProgram* fragmentProgram);
94                ~GLSLLinkProgram(void);
95
96                /** Makes a program object active by making sure it is linked and then putting it in use.
97
98                */
99                void activate(void);
100                /** updates program object uniforms using data from GpuProgramParamters.
101                normally called by GLSLGpuProgram::bindParameters() just before rendering occurs.
102                */
103                void updateUniforms(GpuProgramParametersSharedPtr params, GpuProgramType fromProgType);
104                /** updates program object uniforms using data from pass iteration GpuProgramParamters.
105                normally called by GLSLGpuProgram::bindMultiPassParameters() just before multi pass rendering occurs.
106                */
107                void updatePassIterationUniforms(GpuProgramParametersSharedPtr params);
108                /// get the GL Handle for the program object
109                GLhandleARB getGLHandle(void) const { return mGLHandle; }
110        /** Sets whether the linked program includes the required instructions
111        to perform skeletal animation.
112        @remarks
113        If this is set to true, OGRE will not blend the geometry according to
114        skeletal animation, it will expect the vertex program to do it.
115        */
116        void setSkeletalAnimationIncluded(bool included) 
117        { mSkeletalAnimation = included; }
118
119        /** Returns whether the linked program includes the required instructions
120            to perform skeletal animation.
121        @remarks
122            If this returns true, OGRE will not blend the geometry according to
123            skeletal animation, it will expect the vertex program to do it.
124        */
125        bool isSkeletalAnimationIncluded(void) const { return mSkeletalAnimation; }
126
127                /// Get the index of a non-standard attribute bound in the linked code
128                GLuint getAttributeIndex(VertexElementSemantic semantic);
129                /// Is a non-standard attribute bound in the linked code?
130                bool isAttributeValid(VertexElementSemantic semantic);
131
132        };
133
134}
135
136#endif // __GLSLLinkProgram_H__
Note: See TracBrowser for help on using the repository browser.