OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreShaderFunction.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 _ShaderProgramFunction_
28 #define _ShaderProgramFunction_
29 
31 #include "OgreShaderParameter.h"
32 #include "OgreShaderFunctionAtom.h"
33 
34 namespace Ogre {
35 namespace RTShader {
36 
47 {
48 // Interface.
49 public:
51  {
52  // internal function (default)
54  // Vertex program main
56  // Pixel shader main
57  FFT_PS_MAIN
58  };
59 
61  const String& getName() const { return mName; }
62 
64  const String& getDescription() const { return mDescription; }
65 
74  ParameterPtr resolveInputParameter(Parameter::Semantic semantic, int index, const Parameter::Content content, GpuConstantType type);
75 
76 
85  ParameterPtr resolveOutputParameter(Parameter::Semantic semantic, int index, const Parameter::Content content, GpuConstantType type);
86 
94  ParameterPtr resolveLocalParameter(Parameter::Semantic semantic, int index, const String& name, GpuConstantType type);
95 
103  ParameterPtr resolveLocalParameter(Parameter::Semantic semantic, int index, const Parameter::Content content, GpuConstantType type);
104 
105 
112  static ParameterPtr getParameterByName(const ShaderParameterList& parameterList, const String& name);
113 
121  static ParameterPtr getParameterBySemantic(const ShaderParameterList& parameterList, const Parameter::Semantic semantic, int index);
122 
123 
131  ParameterPtr getParameterByContent(const ShaderParameterList& parameterList, const Parameter::Content content, GpuConstantType type);
132 
134  const ShaderParameterList& getInputParameters() const { return mInputParameters; }
135 
137  const ShaderParameterList& getOutputParameters() const { return mOutputParameters; }
138 
140  const ShaderParameterList& getLocalParameters() const { return mLocalParameters; }
141 
145  void addAtomInstance(FunctionAtom* atomInstance);
146 
150  bool deleteAtomInstance(FunctionAtom* atomInstance);
151 
153  void sortAtomInstances();
154 
156  FunctionAtomInstanceList& getAtomInstances() { return mAtomInstances; }
157 
159  const FunctionAtomInstanceList& getAtomInstances() const { return mAtomInstances; }
160 
162  void addInputParameter(ParameterPtr parameter);
163 
165  void addOutputParameter(ParameterPtr parameter);
166 
168  void deleteInputParameter(ParameterPtr parameter);
169 
171  void deleteOutputParameter(ParameterPtr parameter);
172 
174  void deleteAllInputParameters();
175 
177  void deleteAllOutputParameters();
178 
180  FunctionType getFunctionType() const;
181 
182 
183 protected:
184 
190  Function(const String& name, const String& desc, const FunctionType functionType);
191 
193  ~Function();
194 
196  void addParameter(ShaderParameterList& parameterList, ParameterPtr parameter);
197 
199  void deleteParameter(ShaderParameterList& parameterList, ParameterPtr parameter);
200 
201 protected:
202  // Function name.
204  // Function description.
206  // Input parameters.
208  // Output parameters.
210  // Local parameters.
212  // Atom instances composing this function.
214  // Function type
216 
217 private:
218  friend class Program;
219 };
220 
222 typedef ShaderFunctionList::iterator ShaderFunctionIterator;
223 typedef ShaderFunctionList::const_iterator ShaderFunctionConstIterator;
224 
228 }
229 }
230 
231 #endif
ShaderParameterList mInputParameters
ShaderParameterList mLocalParameters
FunctionAtomInstanceList & getAtomInstances()
Return list of atom instances composing this function.
const ShaderParameterList & getOutputParameters() const
Return a list of output parameters.
FunctionAtomInstanceList mAtomInstances
vector< ParameterPtr >::type ShaderParameterList
const ShaderParameterList & getInputParameters() const
Return a list of input parameters.
const FunctionAtomInstanceList & getAtomInstances() const
Return list of atom instances composing this function.
const String & getDescription() const
Get the description of this function.
#define _OgreRTSSExport
vector< Function * >::type ShaderFunctionList
const String & getName() const
Get the name of this function.
GpuConstantType
Enumeration of the types of constant we may encounter in programs.
A class that represents a shader based program function.
ShaderParameterList mOutputParameters
ShaderFunctionList::iterator ShaderFunctionIterator
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
ShaderFunctionList::const_iterator ShaderFunctionConstIterator
const ShaderParameterList & getLocalParameters() const
Return a list of local parameters.
vector< FunctionAtom * >::type FunctionAtomInstanceList
A class that represents an atomic code section of shader based program function.
A class that represents a shader based program.
_StringBase String