OgreGLSLESProgramCommon.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 __GLSLESProgramCommon_H__
29 #define __GLSLESProgramCommon_H__
30 
31 #include "OgreGLES2Prerequisites.h"
32 #include "OgreGpuProgram.h"
35 #include "OgreGLES2UniformCache.h"
36 
37 namespace Ogre {
38 
39  class GLSLESGpuProgram;
40 
42  struct GLUniformReference
43  {
45  GLint mLocation;
49  const GpuConstantDefinition* mConstantDef;
50  };
51 
53  typedef GLUniformReferenceList::iterator GLUniformReferenceIterator;
55 
56  typedef GLUniformBufferList::iterator GLUniformBufferIterator;
57 
63  {
64  protected:
69 
80  GLint mLinked;
85 
87  void buildGLUniformReferences(void);
89 
91  GLint mCustomAttributesIndexes[VES_COUNT][OGRE_MAX_TEXTURE_COORD_SETS];
93 #define NULL_CUSTOM_ATTRIBUTES_INDEX -2
94 #define NOT_FOUND_CUSTOM_ATTRIBUTES_INDEX -1
96 
97  Ogre::String getCombinedName(void);
99  void getMicrocodeFromCache(void);
101  virtual void compileAndLink(void) = 0;
103  virtual void _useProgram(void) = 0;
104 
107 
108  VertexElementSemantic getAttributeSemanticEnum(String type);
109  const char * getAttributeSemanticString(VertexElementSemantic semantic);
110 
111  public:
113  GLSLESProgramCommon(GLSLESGpuProgram* vertexProgram, GLSLESGpuProgram* fragmentProgram);
114  virtual ~GLSLESProgramCommon(void);
115 
118  virtual void activate(void) = 0;
119 
123  virtual void updateUniforms(GpuProgramParametersSharedPtr params, uint16 mask, GpuProgramType fromProgType) = 0;
127  virtual void updateUniformBlocks(GpuProgramParametersSharedPtr params, uint16 mask, GpuProgramType fromProgType) = 0;
131  virtual void updatePassIterationUniforms(GpuProgramParametersSharedPtr params) = 0;
133  GLuint getGLProgramHandle(void) const { return mGLProgramHandle; }
140  void setSkeletalAnimationIncluded(bool included) { mSkeletalAnimation = included; }
141 
148  bool isSkeletalAnimationIncluded(void) const { return mSkeletalAnimation; }
149 
151  virtual GLint getAttributeIndex(VertexElementSemantic semantic, uint index);
153  bool isAttributeValid(VertexElementSemantic semantic, uint index);
154 
155  GLSLESGpuProgram* getVertexProgram(void) const { return mVertexProgram; }
156  GLSLESGpuProgram* getFragmentProgram(void) const { return mFragmentProgram; }
157  GLES2UniformCache * getUniformCache(void) { return mUniformCache; }
158  };
159 }
160 
161 #endif // __GLSLESProgramCommon_H__
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
OgreGLES2UniformCache.h
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::VES_COUNT
@ VES_COUNT
The number of VertexElementSemantic elements (note - the first value VES_POSITION is 1)
Definition: OgreHardwareVertexBuffer.h:119
OgreHardwareUniformBuffer.h
Ogre::GLSLESProgramCommon::setSkeletalAnimationIncluded
void setSkeletalAnimationIncluded(bool included)
Sets whether the linked program includes the required instructions to perform skeletal animation.
Definition: OgreGLSLESProgramCommon.h:140
Ogre::GLSLESProgramCommon::SemanticToStringMap
map< String, VertexElementSemantic >::type SemanticToStringMap
Definition: OgreGLSLESProgramCommon.h:105
Ogre::uint16
unsigned short uint16
Definition: OgrePlatform.h:360
Ogre::GLES2UniformCache
An in memory cache of the OpenGL ES 2 uniforms.
Definition: OgreGLES2UniformCache.h:41
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::GLSLESProgramCommon::isSkeletalAnimationIncluded
bool isSkeletalAnimationIncluded(void) const
Returns whether the linked program includes the required instructions to perform skeletal animation.
Definition: OgreGLSLESProgramCommon.h:148
Ogre::GLSLESProgramCommon::mUniformRefsBuilt
bool mUniformRefsBuilt
Flag to indicate that uniform references have already been built.
Definition: OgreGLSLESProgramCommon.h:76
Ogre::GLSLESProgramCommon::getUniformCache
GLES2UniformCache * getUniformCache(void)
Definition: OgreGLSLESProgramCommon.h:157
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::vector< GLUniformReference >::type
std::vector< GLUniformReference, STLAllocator< GLUniformReference, GeneralAllocPolicy > > type
Definition: OgrePrerequisites.h:494
OGRE_MAX_TEXTURE_COORD_SETS
#define OGRE_MAX_TEXTURE_COORD_SETS
Define number of texture coordinate sets allowed per vertex.
Definition: OgreConfig.h:68
Ogre::GLSLESProgramCommon::mGLProgramHandle
GLuint mGLProgramHandle
GL handle for the program object.
Definition: OgreGLSLESProgramCommon.h:78
Ogre::GLSLESProgramCommon::mSkeletalAnimation
bool mSkeletalAnimation
Flag indicating skeletal animation is being performed.
Definition: OgreGLSLESProgramCommon.h:84
Ogre::GLSLESProgramCommon::getVertexProgram
GLSLESGpuProgram * getVertexProgram(void) const
Definition: OgreGLSLESProgramCommon.h:155
Ogre::GLSLESProgramCommon::mGLUniformBufferReferences
GLUniformBufferList mGLUniformBufferReferences
Container of uniform buffer references that are active in the program object.
Definition: OgreGLSLESProgramCommon.h:68
Ogre::GLSLESProgramCommon::getFragmentProgram
GLSLESGpuProgram * getFragmentProgram(void) const
Definition: OgreGLSLESProgramCommon.h:156
Ogre::GLUniformBufferIterator
GLUniformBufferList::iterator GLUniformBufferIterator
Definition: OgreGLSLProgramCommon.h:55
Ogre::GLSLESProgramCommon::mLinked
GLint mLinked
Flag indicating that the program or pipeline object has been successfully linked.
Definition: OgreGLSLESProgramCommon.h:80
Ogre::SharedPtr< GpuProgramParameters >
Ogre::GLSLESProgramCommon::mGLUniformReferences
GLUniformReferenceList mGLUniformReferences
Container of uniform references that are active in the program object.
Definition: OgreGLSLESProgramCommon.h:66
OgreHardwareVertexBuffer.h
Ogre::uint
unsigned int uint
Definition: OgrePrerequisites.h:114
Ogre::GLSLESProgramCommon::mSemanticTypeMap
SemanticToStringMap mSemanticTypeMap
Definition: OgreGLSLESProgramCommon.h:106
OgreGpuProgram.h
Ogre::GLSLESProgramCommon::mUniformCache
GLES2UniformCache * mUniformCache
Definition: OgreGLSLESProgramCommon.h:74
_OgreGLES2Export
#define _OgreGLES2Export
Definition: OgreGLES2Prerequisites.h:260
Ogre::GLSLESProgramCommon
C++ encapsulation of GLSL ES Program Object.
Definition: OgreGLSLESProgramCommon.h:62
Ogre::GLUniformReferenceList
vector< GLUniformReference >::type GLUniformReferenceList
Definition: OgreGLSLProgramCommon.h:52
Ogre::GLSLESProgramCommon::getGLProgramHandle
GLuint getGLProgramHandle(void) const
Get the GL Handle for the program object.
Definition: OgreGLSLESProgramCommon.h:133
Ogre::GLSLESProgramCommon::AttributeSet
set< GLuint >::type AttributeSet
Definition: OgreGLSLESProgramCommon.h:88
Ogre::GLSLESProgramCommon::mTriedToLinkAndFailed
bool mTriedToLinkAndFailed
Flag indicating that the program or pipeline object has tried to link and failed.
Definition: OgreGLSLESProgramCommon.h:82
Ogre::GLSLESGpuProgram
GLSL ES low level compiled shader object - this class is used to get at the linked program object and...
Definition: OgreGLSLESGpuProgram.h:47
OgreGLES2Prerequisites.h
Ogre::GLSLESProgramCommon::mVertexProgram
GLSLESGpuProgram * mVertexProgram
Linked vertex program.
Definition: OgreGLSLESProgramCommon.h:71
Ogre::GLSLESProgramCommon::mFragmentProgram
GLSLESGpuProgram * mFragmentProgram
Linked fragment program.
Definition: OgreGLSLESProgramCommon.h:73
Ogre::GLUniformReference::mConstantDef
const GpuConstantDefinition * mConstantDef
The constant definition it relates to.
Definition: OgreGLSLProgramCommon.h:49

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