1 | /*
|
---|
2 | -----------------------------------------------------------------------------
|
---|
3 | This source file is part of OGRE
|
---|
4 | (Object-oriented Graphics Rendering Engine)
|
---|
5 | For the latest info, see http://www.ogre3d.org/
|
---|
6 |
|
---|
7 | Copyright (c) 2000-2005 The OGRE Team
|
---|
8 | Also see acknowledgements in Readme.html
|
---|
9 |
|
---|
10 | This program is free software you can redistribute it and/or modify it under
|
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software
|
---|
12 | Foundation either version 2 of the License, or (at your option) any later
|
---|
13 | version.
|
---|
14 |
|
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT
|
---|
16 | ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS
|
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
---|
18 |
|
---|
19 | You should have received a copy of the GNU Lesser General Public License along with
|
---|
20 | this program if not, write to the Free Software Foundation, Inc., 59 Temple
|
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to
|
---|
22 | http://www.gnu.org/copyleft/lesser.txt.
|
---|
23 | -----------------------------------------------------------------------------
|
---|
24 | */
|
---|
25 | #ifndef __GLSLLinkProgram_H__
|
---|
26 | #define __GLSLLinkProgram_H__
|
---|
27 |
|
---|
28 | #include "OgreGLPrerequisites.h"
|
---|
29 | #include "OgreGpuProgram.h"
|
---|
30 |
|
---|
31 | namespace Ogre {
|
---|
32 |
|
---|
33 | /** C++ encapsulation of GLSL Program Object
|
---|
34 |
|
---|
35 | */
|
---|
36 |
|
---|
37 | class GLSLLinkProgram
|
---|
38 | {
|
---|
39 | private:
|
---|
40 | /// structure used to keep track of named uniforms in the linked program object
|
---|
41 | struct UniformReference
|
---|
42 | {
|
---|
43 | String mName;
|
---|
44 | GLenum mType;
|
---|
45 | GLint mLocation;
|
---|
46 | bool isReal;
|
---|
47 | GLsizei mElementCount;
|
---|
48 | GLint mArraySize;
|
---|
49 | };
|
---|
50 |
|
---|
51 | typedef std::vector<UniformReference> UniformReferenceList;
|
---|
52 | typedef UniformReferenceList::iterator UniformReferenceIterator;
|
---|
53 | /// container of uniform references that are active in the program object
|
---|
54 | UniformReferenceList mUniformReferences;
|
---|
55 |
|
---|
56 | /// flag to indicate that uniform references have already been built
|
---|
57 | bool mUniformRefsBuilt;
|
---|
58 | /// GL handle for the program object
|
---|
59 | GLhandleARB mGLHandle;
|
---|
60 | /// flag indicating that the program object has been successfully linked
|
---|
61 | GLint mLinked;
|
---|
62 | /// flag indicating skeletal animation is being performed
|
---|
63 | bool mSkeletalAnimation;
|
---|
64 |
|
---|
65 | /// build uniform references from active named uniforms
|
---|
66 | void buildUniformReferences(void);
|
---|
67 |
|
---|
68 | public:
|
---|
69 | /// constructor should only be used by GLSLLinkProgramManager
|
---|
70 | GLSLLinkProgram(void);
|
---|
71 | ~GLSLLinkProgram(void);
|
---|
72 |
|
---|
73 | /** Makes a program object active by making sure it is linked and then putting it in use.
|
---|
74 |
|
---|
75 | */
|
---|
76 | void activate(void);
|
---|
77 | /** updates program object uniforms using data from GpuProgramParamters.
|
---|
78 | normally called by GLSLGpuProgram::bindParameters() just before rendering occurs.
|
---|
79 | */
|
---|
80 | void updateUniforms(GpuProgramParametersSharedPtr params);
|
---|
81 | /** updates program object uniforms using data from pass iteration GpuProgramParamters.
|
---|
82 | normally called by GLSLGpuProgram::bindMultiPassParameters() just before multi pass rendering occurs.
|
---|
83 | */
|
---|
84 | void updatePassIterationUniforms(GpuProgramParametersSharedPtr params);
|
---|
85 | /// get the GL Handle for the program object
|
---|
86 | GLhandleARB getGLHandle(void) const { return mGLHandle; }
|
---|
87 | /** Sets whether the linked program includes the required instructions
|
---|
88 | to perform skeletal animation.
|
---|
89 | @remarks
|
---|
90 | If this is set to true, OGRE will not blend the geometry according to
|
---|
91 | skeletal animation, it will expect the vertex program to do it.
|
---|
92 | */
|
---|
93 | void setSkeletalAnimationIncluded(bool included)
|
---|
94 | { mSkeletalAnimation = included; }
|
---|
95 |
|
---|
96 | /** Returns whether the linked program includes the required instructions
|
---|
97 | to perform skeletal animation.
|
---|
98 | @remarks
|
---|
99 | If this returns true, OGRE will not blend the geometry according to
|
---|
100 | skeletal animation, it will expect the vertex program to do it.
|
---|
101 | */
|
---|
102 | bool isSkeletalAnimationIncluded(void) const { return mSkeletalAnimation; }
|
---|
103 |
|
---|
104 | };
|
---|
105 |
|
---|
106 | }
|
---|
107 |
|
---|
108 | #endif // __GLSLLinkProgram_H__
|
---|