OgreGLSLESProgram.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2013 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef __GLSLESProgram_H__
29 #define __GLSLESProgram_H__
30 
31 #include "OgreGLES2Prerequisites.h"
34 
35 namespace Ogre {
51  {
52  public:
53 #if !OGRE_NO_GLES2_GLSL_OPTIMISER
54  class CmdOptimisation : public ParamCommand
56  {
57  public:
58  String doGet(const void* target) const;
59  void doSet(void* target, const String& val);
60  };
61 #endif
64  {
65  public:
66  String doGet(const void* target) const;
67  void doSet(void* target, const String& val);
68  };
69 
71  const String& name, ResourceHandle handle,
72  const String& group, bool isManual, ManualResourceLoader* loader);
73  ~GLSLESProgram();
74 
76  GLuint getGLShaderHandle() const { return mGLShaderHandle; }
77  void attachToProgramObject( const GLuint programObject );
78  void detachFromProgramObject( const GLuint programObject );
79  GLuint getGLProgramHandle() const { return mGLProgramHandle; }
80 
82  bool getPassTransformStates(void) const;
83  bool getPassSurfaceAndLightStates(void) const;
84  bool getPassFogStates(void) const;
85 
87  void setPreprocessorDefines(const String& defines) { mPreprocessorDefines = defines; }
89  const String& getPreprocessorDefines(void) const { return mPreprocessorDefines; }
90 
91 #if !OGRE_NO_GLES2_GLSL_OPTIMISER
92  void setOptimiserEnabled(bool enabled);
95  bool getOptimiserEnabled(void) const { return mOptimiserEnabled; }
96 
98  void setIsOptimised(bool flag) { mIsOptimised = flag; }
100  bool getIsOptimised(void) { return mIsOptimised; }
101 
103  void setOptimisedSource(const String& src) { mOptimisedSource = src; }
105  String getOptimisedSource(void) { return mOptimisedSource; }
106 #endif
107 
109  const String& getLanguage(void) const;
111  GpuProgramParametersSharedPtr createParameters(void);
112 
114  bool compile( const bool checkErrors = false);
115 
116  protected:
118 #if !OGRE_NO_GLES2_GLSL_OPTIMISER
120 #endif
121 
124  void loadFromSource(void);
130  void createLowLevelImpl(void);
132  void unloadHighLevelImpl(void);
134  void unloadImpl(void);
135 
137  void populateParameterNames(GpuProgramParametersSharedPtr params);
139  void buildConstantDefinitions() const;
145  void checkAndFixInvalidDefaultPrecisionError( String &message );
146 
147 #if OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
148 
149  virtual void notifyOnContextLost();
150 #endif
151 
152  private:
157  GLint mCompiled;
160 #if !OGRE_NO_GLES2_GLSL_OPTIMISER
161  bool mIsOptimised;
166 #endif
167  };
168 }
169 
170 #endif // __GLSLESProgram_H__
Ogre::ResourceHandle
unsigned long long int ResourceHandle
Definition: OgreResource.h:41
Ogre
Definition: OgreAndroidLogListener.h:34
OgreHighLevelGpuProgram.h
Ogre::GLSLESProgram::mGLShaderHandle
GLuint mGLShaderHandle
GL handle for shader object.
Definition: OgreGLSLESProgram.h:154
Ogre::GLSLESProgram::CmdPreprocessorDefines
Command object for setting macro defines.
Definition: OgreGLSLESProgram.h:63
Ogre::GLSLESProgram::msCmdPreprocessorDefines
static CmdPreprocessorDefines msCmdPreprocessorDefines
Definition: OgreGLSLESProgram.h:117
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::GLSLESProgram::getPreprocessorDefines
const String & getPreprocessorDefines(void) const
Sets the preprocessor defines use to compile the program.
Definition: OgreGLSLESProgram.h:89
Ogre::ParamCommand
Abstract class which is command object which gets/sets parameters.
Definition: OgreStringInterface.h:79
Ogre::GLSLESProgram::getIsOptimised
bool getIsOptimised(void)
Gets if the GLSL source has been optimised successfully.
Definition: OgreGLSLESProgram.h:100
Ogre::GLSLESProgram::getOptimisedSource
String getOptimisedSource(void)
Gets he optimised GLSL source.
Definition: OgreGLSLESProgram.h:105
Ogre::GLSLESProgram::setIsOptimised
void setIsOptimised(bool flag)
Sets if the GLSL source has been optimised successfully.
Definition: OgreGLSLESProgram.h:98
OgreGLES2ManagedResource.h
Ogre::GLSLESProgram
Specialisation of HighLevelGpuProgram to provide support for OpenGL Shader Language (GLSL ES) for Ope...
Definition: OgreGLSLESProgram.h:50
Ogre::ResourceManager
Defines a generic resource handler.
Definition: OgreResourceManager.h:122
Ogre::GLSLESProgram::setPreprocessorDefines
void setPreprocessorDefines(const String &defines)
Sets the preprocessor defines use to compile the program.
Definition: OgreGLSLESProgram.h:87
Ogre::SharedPtr< GpuProgramParameters >
Ogre::GLSLESProgram::mPreprocessorDefines
String mPreprocessorDefines
Preprocessor options.
Definition: OgreGLSLESProgram.h:159
Ogre::GLSLESProgram::mCompiled
GLint mCompiled
Flag indicating if shader object successfully compiled.
Definition: OgreGLSLESProgram.h:157
Ogre::GLSLESProgram::msCmdOptimisation
static CmdOptimisation msCmdOptimisation
Definition: OgreGLSLESProgram.h:119
MANAGED_RESOURCE
#define MANAGED_RESOURCE
Definition: OgreGLESManagedResource.h:33
Ogre::GLSLESProgram::mGLProgramHandle
GLuint mGLProgramHandle
Definition: OgreGLSLESProgram.h:155
_OgreGLES2Export
#define _OgreGLES2Export
Definition: OgreGLES2Prerequisites.h:260
Ogre::GLSLESProgram::CmdOptimisation
Command object for running the GLSL optimiser.
Definition: OgreGLSLESProgram.h:55
Ogre::GLSLESProgram::getGLProgramHandle
GLuint getGLProgramHandle() const
Definition: OgreGLSLESProgram.h:79
Ogre::GLSLESProgram::mOptimisedSource
String mOptimisedSource
The optmised source of the program (may be blank until the shader is optmisied)
Definition: OgreGLSLESProgram.h:165
Ogre::GLSLESProgram::getOptimiserEnabled
bool getOptimiserEnabled(void) const
Gets if the GLSL optimiser is enabled.
Definition: OgreGLSLESProgram.h:95
Ogre::ManualResourceLoader
Interface describing a manual resource loader.
Definition: OgreResource.h:514
Ogre::GLSLESProgram::mOptimiserEnabled
bool mOptimiserEnabled
Definition: OgreGLSLESProgram.h:163
Ogre::HighLevelGpuProgram
Abstract base class representing a high-level program (a vertex or fragment program).
Definition: OgreHighLevelGpuProgram.h:63
OgreGLES2Prerequisites.h
Ogre::GLSLESProgram::setOptimisedSource
void setOptimisedSource(const String &src)
Sets the optimised GLSL source.
Definition: OgreGLSLESProgram.h:103
Ogre::GLSLESProgram::getGLShaderHandle
GLuint getGLShaderHandle() const
GL Shader Handle.
Definition: OgreGLSLESProgram.h:76

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 Tue Apr 13 2021 08:53:15