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 __GLSLESProgram_H__ 00029 #define __GLSLESProgram_H__ 00030 00031 #include "OgreGLES2Prerequisites.h" 00032 #include "OgreHighLevelGpuProgram.h" 00033 #include "OgreGLES2ManagedResource.h" 00034 00035 namespace Ogre { 00050 class _OgreGLES2Export GLSLESProgram : public HighLevelGpuProgram MANAGED_RESOURCE 00051 { 00052 public: 00053 #if !OGRE_NO_GLES2_GLSL_OPTIMISER 00054 00055 class CmdOptimisation : public ParamCommand 00056 { 00057 public: 00058 String doGet(const void* target) const; 00059 void doSet(void* target, const String& val); 00060 }; 00061 #endif 00062 00063 class CmdPreprocessorDefines : public ParamCommand 00064 { 00065 public: 00066 String doGet(const void* target) const; 00067 void doSet(void* target, const String& val); 00068 }; 00069 00070 GLSLESProgram(ResourceManager* creator, 00071 const String& name, ResourceHandle handle, 00072 const String& group, bool isManual, ManualResourceLoader* loader); 00073 ~GLSLESProgram(); 00074 00076 GLuint getGLShaderHandle() const { return mGLShaderHandle; } 00077 void attachToProgramObject( const GLuint programObject ); 00078 void detachFromProgramObject( const GLuint programObject ); 00079 GLuint getGLProgramHandle() const { return mGLProgramHandle; } 00080 00082 bool getPassTransformStates(void) const; 00083 bool getPassSurfaceAndLightStates(void) const; 00084 bool getPassFogStates(void) const; 00085 00087 void setPreprocessorDefines(const String& defines) { mPreprocessorDefines = defines; } 00089 const String& getPreprocessorDefines(void) const { return mPreprocessorDefines; } 00090 00091 #if !OGRE_NO_GLES2_GLSL_OPTIMISER 00092 00093 void setOptimiserEnabled(bool enabled); 00095 bool getOptimiserEnabled(void) const { return mOptimiserEnabled; } 00096 00098 void setIsOptimised(bool flag) { mIsOptimised = flag; } 00100 bool getIsOptimised(void) { return mIsOptimised; } 00101 00103 void setOptimisedSource(const String& src) { mOptimisedSource = src; } 00105 String getOptimisedSource(void) { return mOptimisedSource; } 00106 #endif 00107 00109 const String& getLanguage(void) const; 00111 GpuProgramParametersSharedPtr createParameters(void); 00112 00114 bool compile( const bool checkErrors = false); 00115 00116 protected: 00117 static CmdPreprocessorDefines msCmdPreprocessorDefines; 00118 #if !OGRE_NO_GLES2_GLSL_OPTIMISER 00119 static CmdOptimisation msCmdOptimisation; 00120 #endif 00121 00124 void loadFromSource(void); 00130 void createLowLevelImpl(void); 00132 void unloadHighLevelImpl(void); 00134 void unloadImpl(void); 00135 00137 void populateParameterNames(GpuProgramParametersSharedPtr params); 00139 void buildConstantDefinitions() const; 00145 void checkAndFixInvalidDefaultPrecisionError( String &message ); 00146 00147 #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID 00148 00149 virtual void notifyOnContextLost(); 00150 #endif 00151 00152 private: 00154 GLuint mGLShaderHandle; 00155 GLuint mGLProgramHandle; 00157 GLint mCompiled; 00159 String mPreprocessorDefines; 00160 #if !OGRE_NO_GLES2_GLSL_OPTIMISER 00161 00162 bool mIsOptimised; 00163 bool mOptimiserEnabled; 00165 String mOptimisedSource; 00166 #endif 00167 }; 00168 } 00169 00170 #endif // __GLSLESProgram_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:42