OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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-2014 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__
Command object for setting macro defines.
#define _OgreGLES2Export
String mOptimisedSource
The optmised source of the program (may be blank until the shader is optmisied)
GLuint mGLShaderHandle
GL handle for shader object.
Interface describing a manual resource loader.
Definition: OgreResource.h:498
bool getIsOptimised(void)
Gets if the GLSL source has been optimised successfully.
void setOptimisedSource(const String &src)
Sets the optimised GLSL source.
GLint mCompiled
Flag indicating if shader object successfully compiled.
Specialisation of HighLevelGpuProgram to provide support for OpenGL Shader Language (GLSL ES) for Ope...
void setPreprocessorDefines(const String &defines)
Sets the preprocessor defines use to compile the program.
#define MANAGED_RESOURCE
GLuint getGLProgramHandle() const
unsigned long long int ResourceHandle
Definition: OgreResource.h:39
static CmdPreprocessorDefines msCmdPreprocessorDefines
GLuint getGLShaderHandle() const
GL Shader Handle.
Defines a generic resource handler.
_StringBase String
Definition: OgreCommon.h:53
String getOptimisedSource(void)
Gets he optimised GLSL source.
static CmdOptimisation msCmdOptimisation
const String & getPreprocessorDefines(void) const
Sets the preprocessor defines use to compile the program.
Abstract base class representing a high-level program (a vertex or fragment program).
void setIsOptimised(bool flag)
Sets if the GLSL source has been optimised successfully.
String mPreprocessorDefines
Preprocessor options.
Command object for running the GLSL optimiser.
bool getOptimiserEnabled(void) const
Gets if the GLSL optimiser is enabled.
Abstract class which is command object which gets/sets parameters.