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:
57 
65 
74 
82 
91 
101  UniformParameterPtr resolveParameter(GpuConstantType type, int index, uint16 variability, const String& suggestedName, size_t size = 0);
102 
108 
114 
121 
124  const UniformParameterList& getParameters() const { return mParameters; };
125 
130  Function* createFunction(const String& name, const String& desc, const Function::FunctionType functionType);
131 
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 
201 
204 
207 
210 
213 
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 
#define _OgreRTSSExport
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
AutoConstantType
Defines the types of automatically updated values that may be bound to GpuProgram parameters,...
A class that represents a shader based program function.
A singleton manager class that manages shader based programs.
A class that represents a shader based program.
const ShaderFunctionList & getFunctions() const
Get the function list of this program.
Program(GpuProgramType type)
Class constructor.
UniformParameterPtr resolveAutoParameterInt(GpuProgramParameters::AutoConstantType autoType, size_t data, size_t size=0)
Resolve uniform auto constant parameter with associated int data of this program.
~Program()
Class destructor.
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.
void destroyFunctions()
Destroy all functions of this program.
const String & getDependency(unsigned int index) const
Get the library name of the given index dependency.
const UniformParameterList & getParameters() const
Get the list of uniform parameters of this program.
ShaderFunctionList mFunctions
UniformParameterPtr resolveParameter(GpuConstantType type, int index, uint16 variability, const String &suggestedName, size_t size=0)
Resolve uniform parameter of this program.
Function * getFunctionByName(const String &name)
Get a function by a given name.
Function * getEntryPointFunction()
Get the entry point function of this program.
void removeParameter(UniformParameterPtr parameter)
Remove parameter from this program.
GpuProgramType getType() const
Get the type of this program.
void addDependency(const String &libFileName)
Add dependency for this program.
Function * createFunction(const String &name, const String &desc, const Function::FunctionType functionType)
Create new function in this program.
size_t getDependencyCount() const
Get the number of external libs this program depends on.
UniformParameterPtr getParameterByName(const String &name)
Get parameter by a given name.
void setUseColumnMajorMatrices(bool value)
Tells Ogre whether auto-bound matrices should be sent in column or row-major order.
void addParameter(UniformParameterPtr parameter)
Add parameter to this program.
UniformParameterPtr getParameterByType(GpuConstantType type, int index)
Get parameter by a given type and index.
void destroyParameters()
Destroy all parameters of this program.
UniformParameterPtr resolveAutoParameterReal(GpuProgramParameters::AutoConstantType autoType, Real data, size_t size=0)
Resolve uniform auto constant parameter with associated real data of this program.
bool getSkeletalAnimationIncluded() const
Returns whether a vertex program includes the required instructions to perform skeletal animation.
UniformParameterList mParameters
bool getUseColumnMajorMatrices() const
Returns whether Ogre will pass auto-bound matrices as column-major.
UniformParameterPtr getParameterByAutoType(GpuProgramParameters::AutoConstantType autoType)
Get parameter by a given auto constant type.
UniformParameterPtr resolveAutoParameterInt(GpuProgramParameters::AutoConstantType autoType, GpuConstantType type, size_t data, size_t size=0)
Resolve uniform auto constant parameter with associated int data of this program.
UniformParameterPtr resolveAutoParameterReal(GpuProgramParameters::AutoConstantType autoType, GpuConstantType type, Real data, size_t size=0)
Resolve uniform auto constant parameter with associated real data of this program.
Reference-counted shared pointer, used for objects where implicit destruction is required.
vector< String >::type StringVector
GpuConstantType
Enumeration of the types of constant we may encounter in programs.
vector< UniformParameterPtr >::type UniformParameterList
vector< Function * >::type ShaderFunctionList
GpuProgramType
Enumerates the types of programs which can run on the GPU.
float Real
Software floating point type.
unsigned short uint16
Definition: OgrePlatform.h:360
_StringBase String

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.