OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreShaderProgram.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-2014 Torus Knot Software Ltd
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14 
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17 
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 THE SOFTWARE.
25 -----------------------------------------------------------------------------
26 */
27 #ifndef _ShaderProgram_
28 #define _ShaderProgram_
29 
31 #include "OgreGpuProgram.h"
32 #include "OgreSingleton.h"
33 #include "OgreShaderParameter.h"
34 #include "OgreShaderFunction.h"
35 #include "OgreShaderFunctionAtom.h"
36 #include "OgreStringVector.h"
37 
38 namespace Ogre {
39 namespace RTShader {
40 
51 {
52 
53 // Interface.
54 public:
56  GpuProgramType getType() const;
57 
64  UniformParameterPtr resolveAutoParameterReal(GpuProgramParameters::AutoConstantType autoType, Real data, size_t size = 0);
65 
73  UniformParameterPtr resolveAutoParameterReal(GpuProgramParameters::AutoConstantType autoType, GpuConstantType type, Real data, size_t size = 0);
74 
81  UniformParameterPtr resolveAutoParameterInt(GpuProgramParameters::AutoConstantType autoType, size_t data, size_t size = 0);
82 
90  UniformParameterPtr resolveAutoParameterInt(GpuProgramParameters::AutoConstantType autoType, GpuConstantType type, size_t data, size_t size = 0);
91 
101  UniformParameterPtr resolveParameter(GpuConstantType type, int index, uint16 variability, const String& suggestedName, size_t size = 0);
102 
107  UniformParameterPtr getParameterByName(const String& name);
108 
113  UniformParameterPtr getParameterByAutoType(GpuProgramParameters::AutoConstantType autoType);
114 
120  UniformParameterPtr getParameterByType(GpuConstantType type, int index);
121 
124  const UniformParameterList& getParameters() const { return mParameters; };
125 
130  Function* createFunction(const String& name, const String& desc, const Function::FunctionType functionType);
131 
135  Function* getFunctionByName(const String& name);
136 
139  const ShaderFunctionList& getFunctions() const { return mFunctions; };
140 
144  void setEntryPointFunction(Function* function) { mEntryPointFunction = function; }
145 
147  Function* getEntryPointFunction() { return mEntryPointFunction; }
148 
154  void addDependency(const String& libFileName);
155 
157  size_t getDependencyCount() const;
158 
162  const String& getDependency(unsigned int index) const;
163 
164 
168  void setSkeletalAnimationIncluded(bool value) { mSkeletalAnimation = value; }
169 
173  bool getSkeletalAnimationIncluded() const { return mSkeletalAnimation; }
174 
186  void setUseColumnMajorMatrices(bool value) { mColumnMajorMatrices = value; }
187 
192  bool getUseColumnMajorMatrices() const { return mColumnMajorMatrices; }
193 
194 // Protected methods.
195 protected:
196 
200  Program(GpuProgramType type);
201 
203  ~Program();
204 
206  void destroyParameters();
207 
209  void destroyFunctions();
210 
212  void addParameter(UniformParameterPtr parameter);
213 
215  void removeParameter(UniformParameterPtr parameter);
216 
217 
218 // Attributes.
219 protected:
220  // Program type. (Vertex, Fragment, Geometry).
222  // Program uniform parameters.
224  // Function list.
226  // Entry point function for this program.
228  // Program dependencies.
230  // Skeletal animation calculation
232  // Whether to pass matrices as column-major.
234 private:
235  friend class ProgramManager;
236 };
237 
241 }
242 }
243 
244 #endif
245 
float Real
Software floating point type.
Function * getEntryPointFunction()
Get the entry point function of this program.
void setUseColumnMajorMatrices(bool value)
Tells Ogre whether auto-bound matrices should be sent in column or row-major order.
GpuProgramType
Enumerates the types of programs which can run on the GPU.
const UniformParameterList & getParameters() const
Get the list of uniform parameters of this program.
#define _OgreRTSSExport
ShaderFunctionList mFunctions
vector< Function * >::type ShaderFunctionList
const ShaderFunctionList & getFunctions() const
Get the function list of this program.
AutoConstantType
Defines the types of automatically updated values that may be bound to GpuProgram parameters...
GpuConstantType
Enumeration of the types of constant we may encounter in programs.
A class that represents a shader based program function.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
vector< UniformParameterPtr >::type UniformParameterList
UniformParameterList mParameters
vector< String >::type StringVector
void setEntryPointFunction(Function *function)
Set the entry point function.
void setSkeletalAnimationIncluded(bool value)
Sets whether a vertex program includes the required instructions to perform skeletal animation...
A class that represents a shader based program.
bool getUseColumnMajorMatrices() const
Returns whether Ogre will pass auto-bound matrices as column-major.
bool getSkeletalAnimationIncluded() const
Returns whether a vertex program includes the required instructions to perform skeletal animation...
Reference-counted shared pointer, used for objects where implicit destruction is required.
_StringBase String
unsigned short uint16
Definition: OgrePlatform.h:345
A singleton manager class that manages shader based programs.