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-2013 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 
Function * getEntryPointFunction()
Get the entry point function of this program.
ShaderFunctionList mFunctions
Reference-counted shared pointer, used for objects where implicit destruction is required.
float Real
Software floating point type.
vector< String >::type StringVector
vector< UniformParameterPtr >::type UniformParameterList
void setSkeletalAnimationIncluded(bool value)
Sets whether a vertex program includes the required instructions to perform skeletal animation...
UniformParameterList mParameters
const ShaderFunctionList & getFunctions() const
Get the function list of this program.
const UniformParameterList & getParameters() const
Get the list of uniform parameters of this program.
bool getUseColumnMajorMatrices() const
Returns whether Ogre will pass auto-bound matrices as column-major.
vector< Function * >::type ShaderFunctionList
AutoConstantType
Defines the types of automatically updated values that may be bound to GpuProgram parameters...
A class that represents a shader based program.
A singleton manager class that manages shader based programs.
_StringBase String
void setEntryPointFunction(Function *function)
Set the entry point function.
GpuProgramType
Enumerates the types of programs which can run on the GPU.
#define _OgreRTSSExport
void setUseColumnMajorMatrices(bool value)
Tells Ogre whether auto-bound matrices should be sent in column or row-major order.
A class that represents a shader based program function.
GpuConstantType
Enumeration of the types of constant we may encounter in programs.
unsigned short uint16
Definition: OgrePlatform.h:360
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
bool getSkeletalAnimationIncluded() const
Returns whether a vertex program includes the required instructions to perform skeletal animation...

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 Sat Sep 20 2014 20:06:38