OGRE  2.0
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 "OgreShaderFunction.h"
34 #include "OgreStringVector.h"
35 
36 namespace Ogre {
37 namespace RTShader {
38 
49 {
50 
51 // Interface.
52 public:
54  GpuProgramType getType() const;
55 
62  UniformParameterPtr resolveAutoParameterReal(GpuProgramParameters::AutoConstantType autoType, Real data, size_t size = 0);
63 
71  UniformParameterPtr resolveAutoParameterReal(GpuProgramParameters::AutoConstantType autoType, GpuConstantType type, Real data, size_t size = 0);
72 
79  UniformParameterPtr resolveAutoParameterInt(GpuProgramParameters::AutoConstantType autoType, size_t data, size_t size = 0);
80 
88  UniformParameterPtr resolveAutoParameterInt(GpuProgramParameters::AutoConstantType autoType, GpuConstantType type, size_t data, size_t size = 0);
89 
99  UniformParameterPtr resolveParameter(GpuConstantType type, int index, uint16 variability, const String& suggestedName, size_t size = 0);
100 
105  UniformParameterPtr getParameterByName(const String& name);
106 
111  UniformParameterPtr getParameterByAutoType(GpuProgramParameters::AutoConstantType autoType);
112 
118  UniformParameterPtr getParameterByType(GpuConstantType type, int index);
119 
122  const UniformParameterList& getParameters() const { return mParameters; };
123 
128  Function* createFunction(const String& name, const String& desc, const Function::FunctionType functionType);
129 
133  Function* getFunctionByName(const String& name);
134 
137  const ShaderFunctionList& getFunctions() const { return mFunctions; };
138 
142  void setEntryPointFunction(Function* function) { mEntryPointFunction = function; }
143 
145  Function* getEntryPointFunction() { return mEntryPointFunction; }
146 
152  void addDependency(const String& libFileName);
153 
155  size_t getDependencyCount() const;
156 
160  const String& getDependency(unsigned int index) const;
161 
162 
166  void setSkeletalAnimationIncluded(bool value) { mSkeletalAnimation = value; }
167 
171  bool getSkeletalAnimationIncluded() const { return mSkeletalAnimation; }
172 
184  void setUseColumnMajorMatrices(bool value) { mColumnMajorMatrices = value; }
185 
190  bool getUseColumnMajorMatrices() const { return mColumnMajorMatrices; }
191 
192 // Protected methods.
193 protected:
194 
198  Program(GpuProgramType type);
199 
201  ~Program();
202 
204  void destroyParameters();
205 
207  void destroyFunctions();
208 
210  void addParameter(UniformParameterPtr parameter);
211 
213  void removeParameter(UniformParameterPtr parameter);
214 
215 
216 // Attributes.
217 protected:
218  // Program type. (Vertex, Fragment, Geometry).
220  // Program uniform parameters.
222  // Function list.
224  // Entry point function for this program.
226  // Program dependencies.
228  // Skeletal animation calculation
230  // Whether to pass matrices as column-major.
232 private:
233  friend class ProgramManager;
234 };
235 
239 }
240 }
241 
242 #endif
243 
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
Definition: OgreCommon.h:53
unsigned short uint16
Definition: OgrePlatform.h:421
A singleton manager class that manages shader based programs.