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 "OgreGL3PlusPrerequisites.h" 00032 #include "OgreHighLevelGpuProgram.h" 00033 00034 namespace Ogre { 00056 class _OgreGL3PlusExport GLSLProgram : public HighLevelGpuProgram 00057 { 00058 public: 00060 class CmdAttach : public ParamCommand 00061 { 00062 public: 00063 String doGet(const void* target) const; 00064 void doSet(void* target, const String& shaderNames); 00065 }; 00066 00068 class CmdPreprocessorDefines : public ParamCommand 00069 { 00070 public: 00071 String doGet(const void* target) const; 00072 void doSet(void* target, const String& val); 00073 }; 00075 class _OgreGL3PlusExport CmdInputOperationType : public ParamCommand 00076 { 00077 public: 00078 String doGet(const void* target) const; 00079 void doSet(void* target, const String& val); 00080 }; 00082 class _OgreGL3PlusExport CmdOutputOperationType : public ParamCommand 00083 { 00084 public: 00085 String doGet(const void* target) const; 00086 void doSet(void* target, const String& val); 00087 }; 00089 class _OgreGL3PlusExport CmdMaxOutputVertices : public ParamCommand 00090 { 00091 public: 00092 String doGet(const void* target) const; 00093 void doSet(void* target, const String& val); 00094 }; 00096 class CmdColumnMajorMatrices : public ParamCommand 00097 { 00098 public: 00099 String doGet(const void* target) const; 00100 void doSet(void* target, const String& val); 00101 }; 00105 virtual RenderOperation::OperationType getInputOperationType(void) const 00106 { return mInputOperationType; } 00109 virtual RenderOperation::OperationType getOutputOperationType(void) const 00110 { return mOutputOperationType; } 00114 virtual int getMaxOutputVertices(void) const { return mMaxOutputVertices; } 00115 00118 virtual void setInputOperationType(RenderOperation::OperationType operationType) 00119 { mInputOperationType = operationType; } 00122 virtual void setOutputOperationType(RenderOperation::OperationType operationType) 00123 { mOutputOperationType = operationType; } 00127 virtual void setMaxOutputVertices(int maxOutputVertices) 00128 { mMaxOutputVertices = maxOutputVertices; } 00129 00130 GLSLProgram(ResourceManager* creator, 00131 const String& name, ResourceHandle handle, 00132 const String& group, bool isManual, ManualResourceLoader* loader); 00133 ~GLSLProgram(); 00134 00135 GLuint getGLShaderHandle() const { return mGLShaderHandle; } 00136 GLuint getGLProgramHandle() const { return mGLProgramHandle; } 00137 void attachToProgramObject( const GLuint programObject ); 00138 void detachFromProgramObject( const GLuint programObject ); 00139 String getAttachedShaderNames() const { return mAttachedShaderNames; } 00140 00142 bool getPassTransformStates(void) const; 00143 bool getPassSurfaceAndLightStates(void) const; 00144 bool getPassFogStates(void) const; 00145 00147 void attachChildShader(const String& name); 00148 00150 void setPreprocessorDefines(const String& defines) { mPreprocessorDefines = defines; } 00152 const String& getPreprocessorDefines(void) const { return mPreprocessorDefines; } 00153 00155 const String& getLanguage(void) const; 00157 void setColumnMajorMatrices(bool columnMajor) { mColumnMajorMatrices = columnMajor; } 00159 bool getColumnMajorMatrices(void) const { return mColumnMajorMatrices; } 00160 00162 GpuProgramParametersSharedPtr createParameters(void); 00163 00165 bool compile( const bool checkErrors = false); 00166 00167 protected: 00168 static CmdPreprocessorDefines msCmdPreprocessorDefines; 00169 static CmdAttach msCmdAttach; 00170 static CmdColumnMajorMatrices msCmdColumnMajorMatrices; 00171 static CmdInputOperationType msInputOperationTypeCmd; 00172 static CmdOutputOperationType msOutputOperationTypeCmd; 00173 static CmdMaxOutputVertices msMaxOutputVerticesCmd; 00174 00177 void loadFromSource(void); 00183 void createLowLevelImpl(void); 00185 void unloadHighLevelImpl(void); 00187 void unloadImpl(void); 00188 00190 void populateParameterNames(GpuProgramParametersSharedPtr params); 00192 void buildConstantDefinitions() const; 00198 void checkAndFixInvalidDefaultPrecisionError( String &message ); 00199 private: 00201 GLuint mGLShaderHandle; 00202 GLuint mGLProgramHandle; 00204 GLint mCompiled; 00206 RenderOperation::OperationType mInputOperationType; 00208 RenderOperation::OperationType mOutputOperationType; 00210 int mMaxOutputVertices; 00212 String mAttachedShaderNames; 00214 String mPreprocessorDefines; 00216 typedef vector< GLSLProgram* >::type GLSLProgramContainer; 00217 typedef GLSLProgramContainer::iterator GLSLProgramContainerIterator; 00218 GLSLProgramContainer mAttachedGLSLPrograms; 00220 bool mColumnMajorMatrices; 00221 }; 00222 } 00223 00224 #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