OgreShaderProgram.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-2013 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 _ShaderProgram_
00028 #define _ShaderProgram_
00029 
00030 #include "OgreShaderPrerequisites.h"
00031 #include "OgreGpuProgram.h"
00032 #include "OgreSingleton.h"
00033 #include "OgreShaderParameter.h"
00034 #include "OgreShaderFunction.h"
00035 #include "OgreShaderFunctionAtom.h"
00036 #include "OgreStringVector.h"
00037 
00038 namespace Ogre {
00039 namespace RTShader {
00040 
00050 class _OgreRTSSExport Program : public RTShaderSystemAlloc
00051 {
00052 
00053 // Interface.
00054 public: 
00056     GpuProgramType getType() const;
00057 
00064     UniformParameterPtr resolveAutoParameterReal(GpuProgramParameters::AutoConstantType autoType, Real data, size_t size = 0);
00065     
00073     UniformParameterPtr resolveAutoParameterReal(GpuProgramParameters::AutoConstantType autoType, GpuConstantType type, Real data, size_t size = 0);
00074 
00081     UniformParameterPtr resolveAutoParameterInt(GpuProgramParameters::AutoConstantType autoType, size_t data, size_t size = 0);
00082     
00090     UniformParameterPtr resolveAutoParameterInt(GpuProgramParameters::AutoConstantType autoType, GpuConstantType type, size_t data, size_t size = 0);
00091 
00101     UniformParameterPtr resolveParameter(GpuConstantType type, int index, uint16 variability, const String& suggestedName, size_t size = 0);
00102     
00107     UniformParameterPtr getParameterByName(const String& name);
00108 
00113     UniformParameterPtr getParameterByAutoType(GpuProgramParameters::AutoConstantType autoType);
00114 
00120     UniformParameterPtr getParameterByType(GpuConstantType type, int index);
00121 
00124     const UniformParameterList& getParameters() const { return mParameters; };
00125 
00130     Function* createFunction(const String& name, const String& desc, const Function::FunctionType functionType);
00131 
00135     Function* getFunctionByName(const String& name);
00136 
00139     const ShaderFunctionList& getFunctions() const { return mFunctions; };
00140 
00144     void setEntryPointFunction(Function* function) { mEntryPointFunction = function; }
00145 
00147     Function* getEntryPointFunction()                    { return mEntryPointFunction; }
00148 
00154     void addDependency(const String& libFileName);
00155 
00157     size_t getDependencyCount() const;
00158 
00162     const String& getDependency(unsigned int index) const;
00163     
00164 
00168     void setSkeletalAnimationIncluded(bool value) { mSkeletalAnimation = value; }
00169  
00173     bool getSkeletalAnimationIncluded() const { return mSkeletalAnimation; }
00174 
00186     void setUseColumnMajorMatrices(bool value) { mColumnMajorMatrices = value; }
00187     
00192     bool getUseColumnMajorMatrices() const { return mColumnMajorMatrices; }
00193 
00194 // Protected methods.
00195 protected:
00196 
00200     Program(GpuProgramType type);
00201 
00203     ~Program();
00204 
00206     void destroyParameters();
00207 
00209     void destroyFunctions();
00210 
00212     void addParameter(UniformParameterPtr parameter);
00213         
00215     void removeParameter(UniformParameterPtr parameter);
00216 
00217 
00218 // Attributes.
00219 protected:
00220     // Program type. (Vertex, Fragment, Geometry).
00221     GpuProgramType mType;
00222     // Program uniform parameters.  
00223     UniformParameterList mParameters;
00224     // Function list.
00225     ShaderFunctionList mFunctions;
00226     // Entry point function for this program.   
00227     Function* mEntryPointFunction;
00228     // Program dependencies.
00229     StringVector mDependencies;
00230     // Skeletal animation calculation
00231     bool mSkeletalAnimation;
00232     // Whether to pass matrices as column-major.
00233     bool mColumnMajorMatrices;
00234 private:
00235     friend class ProgramManager;
00236 };
00237 
00241 }
00242 }
00243 
00244 #endif
00245 

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 Mon Jul 27 2020 13:40:47