OgreGLSLESProgram.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-2012 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 
00034 namespace Ogre {
00049     class _OgreGLES2Export GLSLESProgram : public HighLevelGpuProgram
00050     {
00051     public:
00052 #if !OGRE_NO_GLES2_GLSL_OPTIMISER
00053 
00054         class CmdOptimisation : public ParamCommand
00055         {
00056         public:
00057             String doGet(const void* target) const;
00058             void doSet(void* target, const String& val);
00059         };
00060 #endif
00061 
00062         class CmdPreprocessorDefines : public ParamCommand
00063         {
00064         public:
00065             String doGet(const void* target) const;
00066             void doSet(void* target, const String& val);
00067         };
00068         
00069         GLSLESProgram(ResourceManager* creator, 
00070             const String& name, ResourceHandle handle,
00071             const String& group, bool isManual, ManualResourceLoader* loader);
00072         ~GLSLESProgram();
00073 
00075         GLuint getGLShaderHandle() const { return mGLShaderHandle; }
00076         void attachToProgramObject( const GLuint programObject );
00077         void detachFromProgramObject( const GLuint programObject );
00078         GLuint getGLProgramHandle() const { return mGLProgramHandle; }
00079 
00081         bool getPassTransformStates(void) const;
00082         bool getPassSurfaceAndLightStates(void) const;
00083         bool getPassFogStates(void) const;
00084 
00086         void setPreprocessorDefines(const String& defines) { mPreprocessorDefines = defines; }
00088         const String& getPreprocessorDefines(void) const { return mPreprocessorDefines; }
00089 
00090 #if !OGRE_NO_GLES2_GLSL_OPTIMISER
00091 
00092         void setOptimiserEnabled(bool enabled) { mOptimiserEnabled = enabled; }
00094         bool getOptimiserEnabled(void) const { return mOptimiserEnabled; }
00095         
00097         void setIsOptimised(bool flag) { mIsOptimised = flag; }
00099         bool getIsOptimised(void) { return mIsOptimised; }
00100 #endif
00101 
00103         const String& getLanguage(void) const;
00105         GpuProgramParametersSharedPtr createParameters(void);
00106 
00108         bool compile( const bool checkErrors = false);
00109 
00110     protected:
00111         static CmdPreprocessorDefines msCmdPreprocessorDefines;
00112 #if !OGRE_NO_GLES2_GLSL_OPTIMISER
00113         static CmdOptimisation msCmdOptimisation;
00114 #endif
00115 
00118         void loadFromSource(void);
00124         void createLowLevelImpl(void);
00126         void unloadHighLevelImpl(void);
00128         void unloadImpl(void);
00129 
00131         void populateParameterNames(GpuProgramParametersSharedPtr params);
00133         void buildConstantDefinitions() const;
00139         void checkAndFixInvalidDefaultPrecisionError( String &message );
00140     private:
00142         GLuint mGLShaderHandle;
00143         GLuint mGLProgramHandle;
00145         GLint mCompiled;
00147         bool mIsOptimised;
00149         String mPreprocessorDefines;
00150 #if !OGRE_NO_GLES2_GLSL_OPTIMISER
00151         bool mOptimiserEnabled;
00152 #endif
00153     };
00154 }
00155 
00156 #endif // __GLSLESProgram_H__

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 Sun Sep 2 2012 07:27:21