OGRE: OgreShaderFunction.h Source File - OGRE Documentation

# OgreShaderFunction.h

Go to the documentation of this file.

    00001 /*
    00002 -----------------------------------------------------------------------------
    00003 This source file is part of OGRE
    00004 (Object-oriented Graphics Rendering Engine)
    00005 For the latest info, see http://www.ogre3d.org
    00006
    00007 Copyright (c) 2000-2009 Torus Knot Software Ltd
    00008 Permission is hereby granted, free of charge, to any person obtaining a copy
    00009 of this software and associated documentation files (the "Software"), to deal
    00010 in the Software without restriction, including without limitation the rights
    00011 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    00012 copies of the Software, and to permit persons to whom the Software is
    00013 furnished to do so, subject to the following conditions:
    00014
    00015 The above copyright notice and this permission notice shall be included in
    00016 all copies or substantial portions of the Software.
    00017
    00018 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    00019 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    00020 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    00021 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    00022 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    00023 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    00024 THE SOFTWARE.
    00025 -----------------------------------------------------------------------------
    00026 */
    00027 #ifndef _ShaderProgramFunction_
    00028 #define _ShaderProgramFunction_
    00029
    00030 #include "OgreShaderPrerequisites.h"
    00031 #include "OgreShaderParameter.h"
    00032 #include "OgreShaderFunctionAtom.h"
    00033
    00034 namespace Ogre {
    00035 namespace RTShader {
    00036
    00046 class _OgreRTSSExport Function : public RTShaderSystemAlloc
    00047 {
    00048 // Interface.
    00049 public:
    00050     enum FunctionType
    00051     {
    00052         // internal function (default)
    00053         FFT_INTERNAL,
    00054         // Vertex program main
    00055         FFT_VS_MAIN,
    00056         // Pixel shader main
    00057         FFT_PS_MAIN,
    00058     };
    00059
    00061     const String&               getName                 () const { return m_name; }
    00062
    00064     const String&               getDescription          () const { return m_description; }
    00065
    00074     ParameterPtr                resolveInputParameter   (Parameter::Semantic semantic, int index,  const Parameter::Content content, GpuConstantType type);
    00075
    00076
    00085     ParameterPtr                resolveOutputParameter  (Parameter::Semantic semantic, int index,  const Parameter::Content content, GpuConstantType type);
    00086
    00094     ParameterPtr                resolveLocalParameter   (Parameter::Semantic semantic, int index, const String& name, GpuConstantType type);
    00095
    00103     ParameterPtr                resolveLocalParameter   (Parameter::Semantic semantic, int index, const Parameter::Content content, GpuConstantType type);
    00104
    00105
    00112     static ParameterPtr             getParameterByName      (const ShaderParameterList& parameterList, const String& name);
    00113
    00121     static ParameterPtr             getParameterBySemantic  (const ShaderParameterList& parameterList, const Parameter::Semantic semantic, int index);
    00122
    00123
    00131     ParameterPtr                    getParameterByContent   (const ShaderParameterList& parameterList, const Parameter::Content content, GpuConstantType type);
    00132
    00134     const ShaderParameterList&      getInputParameters      () const { return mInputParameters; }
    00135
    00137     const ShaderParameterList&      getOutputParameters     () const { return mOutputParameters; }
    00138
    00140     const ShaderParameterList&      getLocalParameters      () const { return mLocalParameters; }
    00141
    00145     void                            addAtomInstace          (FunctionAtom* atomInstance);
    00146
    00150     bool                            deleteAtomInstance      (FunctionAtom* atomInstance);
    00151
    00153     void                            sortAtomInstances       ();
    00154
    00156     FunctionAtomInstanceList&       getAtomInstances        () { return mAtomInstances; }
    00157
    00159     const FunctionAtomInstanceList& getAtomInstances        () const { return mAtomInstances; }
    00160
    00162     void                        addInputParameter           (ParameterPtr parameter);
    00163
    00165     void                        addOutputParameter          (ParameterPtr parameter);
    00166
    00168     void                        deleteInputParameter        (ParameterPtr parameter);
    00169
    00171     void                        deleteOutputParameter       (ParameterPtr parameter);
    00172
    00174     void                        deleteAllInputParameters    ();
    00175
    00177     void                        deleteAllOutputParameters   ();
    00178
    00180     FunctionType getFunctionType() const;
    00181
    00182
    00183 protected:
    00184
    00190     Function            (const String& name, const String& desc, const FunctionType functionType);
    00191
    00193     ~Function           ();
    00194
    00196     void                        addParameter                (ShaderParameterList& parameterList, ParameterPtr parameter);
    00197
    00199     void                        deleteParameter             (ShaderParameterList& parameterList, ParameterPtr parameter);
    00200
    00202     static int                  sAtomInstanceCompare        (const void * p0, const void *p1);
    00203
    00204 protected:
    00205     String                      m_name;                     // Function name.
    00206     String                      m_description;              // Function description.
    00207     ShaderParameterList         mInputParameters;           // Input parameters.
    00208     ShaderParameterList         mOutputParameters;          // Output parameters.
    00209     ShaderParameterList         mLocalParameters;           // Local parameters.
    00210     FunctionAtomInstanceList    mAtomInstances;             // Atom instances composing this function.
    00211     FunctionType                m_functionType;             // Function type
    00212
    00213 private:
    00214     friend class Program;
    00215 };
    00216
    00217 typedef vector<Function*>::type                     ShaderFunctionList;
    00218 typedef ShaderFunctionList::iterator                ShaderFunctionIterator;
    00219 typedef ShaderFunctionList::const_iterator          ShaderFunctionConstIterator;
    00220
    00224 }
    00225 }
    00226
    00227 #endif

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Nov 3 2010 19:24:52