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 00009 Permission is hereby granted, free of charge, to any person obtaining a copy 00010 of this software and associated documentation files (the "Software"), to deal 00011 in the Software without restriction, including without limitation the rights 00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00013 copies of the Software, and to permit persons to whom the Software is 00014 furnished to do so, subject to the following conditions: 00015 00016 The above copyright notice and this permission notice shall be included in 00017 all copies or substantial portions of the Software. 00018 00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00025 THE SOFTWARE. 00026 ----------------------------------------------------------------------------- 00027 */ 00028 #ifndef __GLSLProgram_H__ 00029 #define __GLSLProgram_H__ 00030 00031 #include "OgreGLPrerequisites.h" 00032 #include "OgreHighLevelGpuProgram.h" 00033 00034 namespace Ogre { 00035 namespace GLSL { 00057 class _OgreGLExport GLSLProgram : public HighLevelGpuProgram 00058 { 00059 public: 00061 class CmdAttach : public ParamCommand 00062 { 00063 public: 00064 String doGet(const void* target) const; 00065 void doSet(void* target, const String& shaderNames); 00066 }; 00068 class CmdColumnMajorMatrices : public ParamCommand 00069 { 00070 public: 00071 String doGet(const void* target) const; 00072 void doSet(void* target, const String& val); 00073 }; 00074 00075 GLSLProgram(ResourceManager* creator, 00076 const String& name, ResourceHandle handle, 00077 const String& group, bool isManual, ManualResourceLoader* loader); 00078 ~GLSLProgram(); 00079 00080 GLhandleARB getGLHandle() const { return mGLHandle; } 00081 void attachToProgramObject( const GLhandleARB programObject ); 00082 void detachFromProgramObject( const GLhandleARB programObject ); 00083 String getAttachedShaderNames() const { return mAttachedShaderNames; } 00084 00086 bool getPassTransformStates(void) const; 00087 bool getPassSurfaceAndLightStates(void) const; 00088 00090 void attachChildShader(const String& name); 00091 00093 void setPreprocessorDefines(const String& defines) { mPreprocessorDefines = defines; } 00095 const String& getPreprocessorDefines(void) const { return mPreprocessorDefines; } 00096 00098 const String& getLanguage(void) const; 00099 00101 void setColumnMajorMatrices(bool columnMajor) { mColumnMajorMatrices = columnMajor; } 00103 bool getColumnMajorMatrices(void) const { return mColumnMajorMatrices; } 00104 00108 virtual RenderOperation::OperationType getInputOperationType(void) const 00109 { return mInputOperationType; } 00112 virtual RenderOperation::OperationType getOutputOperationType(void) const 00113 { return mOutputOperationType; } 00117 virtual int getMaxOutputVertices(void) const { return mMaxOutputVertices; } 00118 00121 virtual void setInputOperationType(RenderOperation::OperationType operationType) 00122 { mInputOperationType = operationType; } 00125 virtual void setOutputOperationType(RenderOperation::OperationType operationType) 00126 { mOutputOperationType = operationType; } 00130 virtual void setMaxOutputVertices(int maxOutputVertices) 00131 { mMaxOutputVertices = maxOutputVertices; } 00132 00134 bool compile( const bool checkErrors = true); 00135 00137 class CmdPreprocessorDefines : public ParamCommand 00138 { 00139 public: 00140 String doGet(const void* target) const; 00141 void doSet(void* target, const String& val); 00142 }; 00144 class _OgreGLExport CmdInputOperationType : public ParamCommand 00145 { 00146 public: 00147 String doGet(const void* target) const; 00148 void doSet(void* target, const String& val); 00149 }; 00151 class _OgreGLExport CmdOutputOperationType : public ParamCommand 00152 { 00153 public: 00154 String doGet(const void* target) const; 00155 void doSet(void* target, const String& val); 00156 }; 00158 class _OgreGLExport CmdMaxOutputVertices : public ParamCommand 00159 { 00160 public: 00161 String doGet(const void* target) const; 00162 void doSet(void* target, const String& val); 00163 }; 00164 protected: 00165 static CmdPreprocessorDefines msCmdPreprocessorDefines; 00166 static CmdAttach msCmdAttach; 00167 static CmdColumnMajorMatrices msCmdColumnMajorMatrices; 00168 static CmdInputOperationType msInputOperationTypeCmd; 00169 static CmdOutputOperationType msOutputOperationTypeCmd; 00170 static CmdMaxOutputVertices msMaxOutputVerticesCmd; 00171 00174 void loadFromSource(void); 00180 void createLowLevelImpl(void); 00182 void unloadHighLevelImpl(void); 00184 void unloadImpl(void); 00185 00187 void populateParameterNames(GpuProgramParametersSharedPtr params); 00189 void buildConstantDefinitions() const; 00190 00191 private: 00193 GLhandleARB mGLHandle; 00195 GLint mCompiled; 00197 RenderOperation::OperationType mInputOperationType; 00199 RenderOperation::OperationType mOutputOperationType; 00201 int mMaxOutputVertices; 00203 String mAttachedShaderNames; 00205 String mPreprocessorDefines; 00207 typedef vector< GLSLProgram* >::type GLSLProgramContainer; 00208 typedef GLSLProgramContainer::iterator GLSLProgramContainerIterator; 00209 GLSLProgramContainer mAttachedGLSLPrograms; 00211 bool mColumnMajorMatrices; 00212 00213 }; 00214 } 00215 } 00216 00217 #endif // __GLSLProgram_H__
Copyright © 2012 Torus Knot Software Ltd

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jul 27 2020 13:40:43