OgreGLSLProgramCommon.h
Go to the documentation of this file.
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-2013 Torus Knot Software Ltd
8 
9  Permission is hereby granted, free of charge, to any person obtaining a copy
10  of this software and associated documentation files (the "Software"), to deal
11  in the Software without restriction, including without limitation the rights
12  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13  copies of the Software, and to permit persons to whom the Software is
14  furnished to do so, subject to the following conditions:
15 
16  The above copyright notice and this permission notice shall be included in
17  all copies or substantial portions of the Software.
18 
19  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25  THE SOFTWARE.
26  -----------------------------------------------------------------------------
27  */
28 #ifndef __GLSLProgramCommon_H__
29 #define __GLSLProgramCommon_H__
30 
32 #include "OgreGpuProgram.h"
36 
37 namespace Ogre {
38 
39  class GLSLGpuProgram;
40 
43  {
45  GLint mLocation;
50  };
51 
53  typedef GLUniformReferenceList::iterator GLUniformReferenceIterator;
55  typedef GLUniformBufferList::iterator GLUniformBufferIterator;
56 
62  {
63  protected:
66 
69 
84 
90  GLint mLinked;
95 
97  void buildGLUniformReferences(void);
99 
101  GLint mCustomAttributesIndexes[VES_COUNT][OGRE_MAX_TEXTURE_COORD_SETS];
103 #define NULL_CUSTOM_ATTRIBUTES_INDEX -2
104 #define NOT_FOUND_CUSTOM_ATTRIBUTES_INDEX -1
106 
107  Ogre::String getCombinedName(void);
109  void getMicrocodeFromCache(void);
111  virtual void compileAndLink(void) = 0;
113  virtual void _useProgram(void) = 0;
114 
117 
118  VertexElementSemantic getAttributeSemanticEnum(String type);
119  const char * getAttributeSemanticString(VertexElementSemantic semantic);
120 
121  public:
123  GLSLProgramCommon(GLSLGpuProgram* vertexProgram, GLSLGpuProgram* geometryProgram, GLSLGpuProgram* fragmentProgram, GLSLGpuProgram* hullProgram, GLSLGpuProgram* domainProgram, GLSLGpuProgram* computeProgram);
124  virtual ~GLSLProgramCommon(void);
125 
128  virtual void activate(void) = 0;
129 
133  virtual void updateUniforms(GpuProgramParametersSharedPtr params, uint16 mask, GpuProgramType fromProgType) = 0;
137  virtual void updateUniformBlocks(GpuProgramParametersSharedPtr params, uint16 mask, GpuProgramType fromProgType) = 0;
141  virtual void updatePassIterationUniforms(GpuProgramParametersSharedPtr params) = 0;
143  virtual void extractLayoutQualifiers(void);
145  GLuint getGLProgramHandle(void) const { return mGLProgramHandle; }
152  void setSkeletalAnimationIncluded(bool included) { mSkeletalAnimation = included; }
153 
160  bool isSkeletalAnimationIncluded(void) const { return mSkeletalAnimation; }
161 
163  virtual GLint getAttributeIndex(VertexElementSemantic semantic, uint index);
165  bool isAttributeValid(VertexElementSemantic semantic, uint index);
166 
167  GLSLGpuProgram* getVertexProgram() const { return mVertexProgram; }
168  GLSLGpuProgram* getFragmentProgram() const { return mFragmentProgram; }
169  GLSLGpuProgram* getGeometryProgram() const { return mGeometryProgram; }
170  GLSLGpuProgram* getHullProgram() const { return mHullProgram; }
171  GLSLGpuProgram* getDomainProgram() const { return mDomainProgram; }
172  GLSLGpuProgram* getComputeProgram() const { return mComputeProgram; }
173  GL3PlusVertexArrayObject* getVertexArrayObject() { return mVertexArrayObject; }
174  };
175 }
176 
177 #endif // __GLSLProgramCommon_H__
Ogre::GLSLProgramCommon::mVertexArrayObject
GL3PlusVertexArrayObject * mVertexArrayObject
GL handle for the vertex array object.
Definition: OgreGLSLProgramCommon.h:83
Ogre::GLUniformReference::mSourceProgType
GpuProgramType mSourceProgType
Which type of program params will this value come from?
Definition: OgreGLSLProgramCommon.h:47
Ogre::GLUniformReference::mLocation
GLint mLocation
GL location handle.
Definition: OgreGLSLProgramCommon.h:45
Ogre::GLSLProgramCommon::mHullProgram
GLSLGpuProgram * mHullProgram
Linked hull(control) program.
Definition: OgreGLSLProgramCommon.h:77
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::GLUniformReferenceIterator
GLUniformReferenceList::iterator GLUniformReferenceIterator
Definition: OgreGLSLProgramCommon.h:53
Ogre::GLUniformBufferList
vector< HardwareUniformBufferSharedPtr >::type GLUniformBufferList
Definition: OgreGLSLProgramCommon.h:54
Ogre::map
Definition: OgrePrerequisites.h:533
Ogre::set
Definition: OgrePrerequisites.h:519
Ogre::GLSLProgramCommon::getGeometryProgram
GLSLGpuProgram * getGeometryProgram() const
Definition: OgreGLSLProgramCommon.h:169
Ogre::GLSLProgramCommon::mSkeletalAnimation
bool mSkeletalAnimation
Flag indicating skeletal animation is being performed.
Definition: OgreGLSLProgramCommon.h:94
Ogre::VES_COUNT
@ VES_COUNT
The number of VertexElementSemantic elements (note - the first value VES_POSITION is 1)
Definition: OgreHardwareVertexBuffer.h:119
Ogre::GLSLProgramCommon::mTriedToLinkAndFailed
bool mTriedToLinkAndFailed
Flag indicating that the program or pipeline object has tried to link and failed.
Definition: OgreGLSLProgramCommon.h:92
Ogre::uint16
unsigned short uint16
Definition: OgrePlatform.h:360
Ogre::GLSLProgramCommon::mGLUniformReferences
GLUniformReferenceList mGLUniformReferences
Container of uniform references that are active in the program object.
Definition: OgreGLSLProgramCommon.h:65
Ogre::GLSLProgramCommon::getVertexArrayObject
GL3PlusVertexArrayObject * getVertexArrayObject()
Definition: OgreGLSLProgramCommon.h:173
Ogre::GLSLProgramCommon::getFragmentProgram
GLSLGpuProgram * getFragmentProgram() const
Definition: OgreGLSLProgramCommon.h:168
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::GLSLProgramCommon::mSemanticTypeMap
SemanticToStringMap mSemanticTypeMap
Definition: OgreGLSLProgramCommon.h:116
Ogre::GLSLProgramCommon::mGLProgramHandle
GLuint mGLProgramHandle
GL handle for the program object.
Definition: OgreGLSLProgramCommon.h:88
Ogre::GLSLProgramCommon::mGLUniformBufferReferences
GLUniformBufferList mGLUniformBufferReferences
Container of uniform buffer references that are active in the program object.
Definition: OgreGLSLProgramCommon.h:68
Ogre::GpuProgramType
GpuProgramType
Enumerates the types of programs which can run on the GPU.
Definition: OgreGpuProgram.h:50
Ogre::VertexElementSemantic
VertexElementSemantic
Vertex element semantics, used to identify the meaning of vertex buffer contents.
Definition: OgreHardwareVertexBuffer.h:99
Ogre::GLSLProgramCommon::setSkeletalAnimationIncluded
void setSkeletalAnimationIncluded(bool included)
Sets whether the linked program includes the required instructions to perform skeletal animation.
Definition: OgreGLSLProgramCommon.h:152
Ogre::GLSLProgramCommon
C++ encapsulation of GLSL Program Object.
Definition: OgreGLSLProgramCommon.h:61
OGRE_MAX_TEXTURE_COORD_SETS
#define OGRE_MAX_TEXTURE_COORD_SETS
Define number of texture coordinate sets allowed per vertex.
Definition: OgreConfig.h:68
_OgreGL3PlusExport
#define _OgreGL3PlusExport
Definition: OgreGL3PlusPrerequisites.h:91
OgreGL3PlusHardwareUniformBuffer.h
Ogre::GLSLGpuProgram
GLSL low level compiled shader object - this class is used to get at the linked program object and pr...
Definition: Plus/src/GLSL/include/OgreGLSLGpuProgram.h:48
OgreGL3PlusVertexArrayObject.h
Ogre::GLSLProgramCommon::mGeometryProgram
GLSLGpuProgram * mGeometryProgram
Linked geometry program.
Definition: OgreGLSLProgramCommon.h:75
Ogre::GLSLProgramCommon::getDomainProgram
GLSLGpuProgram * getDomainProgram() const
Definition: OgreGLSLProgramCommon.h:171
Ogre::GLSLProgramCommon::mDomainProgram
GLSLGpuProgram * mDomainProgram
Linked domain(evaluation) program.
Definition: OgreGLSLProgramCommon.h:79
OgreGL3PlusPrerequisites.h
Ogre::GLSLProgramCommon::mUniformRefsBuilt
bool mUniformRefsBuilt
Flag to indicate that uniform references have already been built.
Definition: OgreGLSLProgramCommon.h:86
Ogre::GLUniformBufferIterator
GLUniformBufferList::iterator GLUniformBufferIterator
Definition: OgreGLSLProgramCommon.h:55
Ogre::SharedPtr< GpuProgramParameters >
OgreHardwareVertexBuffer.h
Ogre::GLSLProgramCommon::isSkeletalAnimationIncluded
bool isSkeletalAnimationIncluded(void) const
Returns whether the linked program includes the required instructions to perform skeletal animation.
Definition: OgreGLSLProgramCommon.h:160
Ogre::GLSLProgramCommon::getVertexProgram
GLSLGpuProgram * getVertexProgram() const
Definition: OgreGLSLProgramCommon.h:167
Ogre::uint
unsigned int uint
Definition: OgrePrerequisites.h:114
Ogre::GpuConstantDefinition
Information about predefined program constants.
Definition: OgreGpuProgramParams.h:122
Ogre::GLSLProgramCommon::mVertexProgram
GLSLGpuProgram * mVertexProgram
Linked vertex program.
Definition: OgreGLSLProgramCommon.h:71
OgreGpuProgram.h
Ogre::GLSLProgramCommon::mFragmentProgram
GLSLGpuProgram * mFragmentProgram
Linked fragment program.
Definition: OgreGLSLProgramCommon.h:73
Ogre::GLSLProgramCommon::mLinked
GLint mLinked
Flag indicating that the program or pipeline object has been successfully linked.
Definition: OgreGLSLProgramCommon.h:90
Ogre::GLSLProgramCommon::SemanticToStringMap
map< String, VertexElementSemantic >::type SemanticToStringMap
Definition: OgreGLSLProgramCommon.h:115
Ogre::GL3PlusVertexArrayObject
Specialisation of VertexDeclaration for OpenGL Vertex Array Object usage.
Definition: OgreGL3PlusVertexArrayObject.h:37
Ogre::GLUniformReferenceList
vector< GLUniformReference >::type GLUniformReferenceList
Definition: OgreGLSLProgramCommon.h:52
Ogre::vector
Definition: OgrePrerequisites.h:491
Ogre::GLSLProgramCommon::getComputeProgram
GLSLGpuProgram * getComputeProgram() const
Definition: OgreGLSLProgramCommon.h:172
Ogre::GLSLProgramCommon::AttributeSet
set< GLuint >::type AttributeSet
Definition: OgreGLSLProgramCommon.h:98
Ogre::GLSLProgramCommon::getGLProgramHandle
GLuint getGLProgramHandle(void) const
Get the GL Handle for the program object.
Definition: OgreGLSLProgramCommon.h:145
Ogre::GLSLProgramCommon::mComputeProgram
GLSLGpuProgram * mComputeProgram
Linked compute program.
Definition: OgreGLSLProgramCommon.h:81
Ogre::GLSLProgramCommon::getHullProgram
GLSLGpuProgram * getHullProgram() const
Definition: OgreGLSLProgramCommon.h:170
Ogre::GLUniformReference::mConstantDef
const GpuConstantDefinition * mConstantDef
The constant definition it relates to.
Definition: OgreGLSLProgramCommon.h:49
Ogre::GLUniformReference
Structure used to keep track of named uniforms in the linked program object.
Definition: OgreGLSLProgramCommon.h:42

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Tue Apr 13 2021 08:53:15