src/GLSL/include/OgreGLSLProgram.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 __GLSLProgram_H__
29 #define __GLSLProgram_H__
30 
31 #include "OgreGLPrerequisites.h"
33 
34 namespace Ogre {
35  namespace GLSL {
58  {
59  public:
61  class CmdAttach : public ParamCommand
62  {
63  public:
64  String doGet(const void* target) const;
65  void doSet(void* target, const String& shaderNames);
66  };
69  {
70  public:
71  String doGet(const void* target) const;
72  void doSet(void* target, const String& val);
73  };
74 
75  GLSLProgram(ResourceManager* creator,
76  const String& name, ResourceHandle handle,
77  const String& group, bool isManual, ManualResourceLoader* loader);
78  ~GLSLProgram();
79 
80  GLhandleARB getGLHandle() const { return mGLHandle; }
81  void attachToProgramObject( const GLhandleARB programObject );
82  void detachFromProgramObject( const GLhandleARB programObject );
83  String getAttachedShaderNames() const { return mAttachedShaderNames; }
84 
86  bool getPassTransformStates(void) const;
87  bool getPassSurfaceAndLightStates(void) const;
88 
90  void attachChildShader(const String& name);
91 
93  void setPreprocessorDefines(const String& defines) { mPreprocessorDefines = defines; }
95  const String& getPreprocessorDefines(void) const { return mPreprocessorDefines; }
96 
98  const String& getLanguage(void) const;
99 
101  void setColumnMajorMatrices(bool columnMajor) { mColumnMajorMatrices = columnMajor; }
103  bool getColumnMajorMatrices(void) const { return mColumnMajorMatrices; }
104 
109  { return mInputOperationType; }
113  { return mOutputOperationType; }
117  virtual int getMaxOutputVertices(void) const { return mMaxOutputVertices; }
118 
122  { mInputOperationType = operationType; }
126  { mOutputOperationType = operationType; }
130  virtual void setMaxOutputVertices(int maxOutputVertices)
131  { mMaxOutputVertices = maxOutputVertices; }
132 
134  bool compile( const bool checkErrors = true);
135 
138  {
139  public:
140  String doGet(const void* target) const;
141  void doSet(void* target, const String& val);
142  };
145  {
146  public:
147  String doGet(const void* target) const;
148  void doSet(void* target, const String& val);
149  };
152  {
153  public:
154  String doGet(const void* target) const;
155  void doSet(void* target, const String& val);
156  };
159  {
160  public:
161  String doGet(const void* target) const;
162  void doSet(void* target, const String& val);
163  };
164  protected:
171 
174  void loadFromSource(void);
180  void createLowLevelImpl(void);
182  void unloadHighLevelImpl(void);
184  void unloadImpl(void);
185 
187  void populateParameterNames(GpuProgramParametersSharedPtr params);
189  void buildConstantDefinitions() const;
190 
191  private:
193  GLhandleARB mGLHandle;
195  GLint mCompiled;
208  typedef GLSLProgramContainer::iterator GLSLProgramContainerIterator;
212 
213  };
214  }
215 }
216 
217 #endif // __GLSLProgram_H__
Ogre::ResourceHandle
unsigned long long int ResourceHandle
Definition: OgreResource.h:41
Ogre::GLSL::GLSLProgram::setMaxOutputVertices
virtual void setMaxOutputVertices(int maxOutputVertices)
Set the maximum number of vertices that a single run of this geometry program can emit.
Definition: src/GLSL/include/OgreGLSLProgram.h:130
Ogre::GLSL::GLSLProgram::msCmdColumnMajorMatrices
static CmdColumnMajorMatrices msCmdColumnMajorMatrices
Definition: src/GLSL/include/OgreGLSLProgram.h:167
Ogre::GLSL::GLSLProgram::GLSLProgramContainerIterator
GLSLProgramContainer::iterator GLSLProgramContainerIterator
Definition: src/GLSL/include/OgreGLSLProgram.h:208
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::GLSL::GLSLProgram::getPreprocessorDefines
const String & getPreprocessorDefines(void) const
Sets the preprocessor defines use to compile the program.
Definition: src/GLSL/include/OgreGLSLProgram.h:95
Ogre::GLSL::GLSLProgram::getColumnMajorMatrices
bool getColumnMajorMatrices(void) const
Gets whether matrix packed in column-major order.
Definition: src/GLSL/include/OgreGLSLProgram.h:103
Ogre::GLSL::GLSLProgram::getMaxOutputVertices
virtual int getMaxOutputVertices(void) const
Returns the maximum number of vertices that this geometry program can output in a single run.
Definition: src/GLSL/include/OgreGLSLProgram.h:117
Ogre::GLSL::GLSLProgram::setPreprocessorDefines
void setPreprocessorDefines(const String &defines)
Sets the preprocessor defines use to compile the program.
Definition: src/GLSL/include/OgreGLSLProgram.h:93
OgreHighLevelGpuProgram.h
Ogre::GLSL::GLSLProgram::getInputOperationType
virtual RenderOperation::OperationType getInputOperationType(void) const
Returns the operation type that this geometry program expects to receive as input.
Definition: src/GLSL/include/OgreGLSLProgram.h:108
Ogre::GLSL::GLSLProgram::mPreprocessorDefines
String mPreprocessorDefines
Preprocessor options.
Definition: src/GLSL/include/OgreGLSLProgram.h:205
Ogre::GLSL::GLSLProgram::setOutputOperationType
virtual void setOutputOperationType(RenderOperation::OperationType operationType)
Set the operation type that this geometry program will emit.
Definition: src/GLSL/include/OgreGLSLProgram.h:125
Ogre::GLSL::GLSLProgram::CmdMaxOutputVertices
Command object for setting the maximum output vertices (geometry shader only)
Definition: src/GLSL/include/OgreGLSLProgram.h:158
Ogre::GLSL::GLSLProgram::mMaxOutputVertices
int mMaxOutputVertices
The maximum amount of vertices that this (geometry) program can output.
Definition: src/GLSL/include/OgreGLSLProgram.h:201
Ogre::GLSL::GLSLProgram::CmdOutputOperationType
Command object for setting the output operation type (geometry shader only)
Definition: src/GLSL/include/OgreGLSLProgram.h:151
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::GLSL::GLSLProgram::CmdAttach
Command object for attaching another GLSL Program.
Definition: src/GLSL/include/OgreGLSLProgram.h:61
Ogre::GLSL::GLSLProgram::msInputOperationTypeCmd
static CmdInputOperationType msInputOperationTypeCmd
Definition: src/GLSL/include/OgreGLSLProgram.h:168
Ogre::ParamCommand
Abstract class which is command object which gets/sets parameters.
Definition: OgreStringInterface.h:79
Ogre::GLSL::GLSLProgram::GLSLProgramContainer
vector< GLSLProgram * >::type GLSLProgramContainer
Container of attached programs.
Definition: src/GLSL/include/OgreGLSLProgram.h:207
Ogre::GLSL::GLSLProgram::mGLHandle
GLhandleARB mGLHandle
GL handle for shader object.
Definition: src/GLSL/include/OgreGLSLProgram.h:193
Ogre::GLSL::GLSLProgram::msCmdPreprocessorDefines
static CmdPreprocessorDefines msCmdPreprocessorDefines
Definition: src/GLSL/include/OgreGLSLProgram.h:165
Ogre::GLSL::GLSLProgram::mCompiled
GLint mCompiled
Flag indicating if shader object successfully compiled.
Definition: src/GLSL/include/OgreGLSLProgram.h:195
_OgreGLExport
#define _OgreGLExport
Definition: OgreGLPrerequisites.h:99
OgreGLPrerequisites.h
Ogre::GLSL::GLSLProgram::mAttachedGLSLPrograms
GLSLProgramContainer mAttachedGLSLPrograms
Definition: src/GLSL/include/OgreGLSLProgram.h:209
Ogre::GLSL::GLSLProgram::msCmdAttach
static CmdAttach msCmdAttach
Definition: src/GLSL/include/OgreGLSLProgram.h:166
Ogre::GLSL::GLSLProgram::CmdInputOperationType
Command object for setting the input operation type (geometry shader only)
Definition: src/GLSL/include/OgreGLSLProgram.h:144
Ogre::GLSL::GLSLProgram::mOutputOperationType
RenderOperation::OperationType mOutputOperationType
The output operation type for this (geometry) program.
Definition: src/GLSL/include/OgreGLSLProgram.h:199
Ogre::GLSL::GLSLProgram::mInputOperationType
RenderOperation::OperationType mInputOperationType
The input operation type for this (geometry) program.
Definition: src/GLSL/include/OgreGLSLProgram.h:197
Ogre::ResourceManager
Defines a generic resource handler.
Definition: OgreResourceManager.h:122
Ogre::GLSL::GLSLProgram::setInputOperationType
virtual void setInputOperationType(RenderOperation::OperationType operationType)
Sets the operation type that this geometry program expects to receive.
Definition: src/GLSL/include/OgreGLSLProgram.h:121
Ogre::GLSL::GLSLProgram::CmdColumnMajorMatrices
Command object for setting matrix packing in column-major order.
Definition: src/GLSL/include/OgreGLSLProgram.h:68
Ogre::SharedPtr< GpuProgramParameters >
Ogre::GLSL::GLSLProgram::msOutputOperationTypeCmd
static CmdOutputOperationType msOutputOperationTypeCmd
Definition: src/GLSL/include/OgreGLSLProgram.h:169
Ogre::GLSL::GLSLProgram::msMaxOutputVerticesCmd
static CmdMaxOutputVertices msMaxOutputVerticesCmd
Definition: src/GLSL/include/OgreGLSLProgram.h:170
Ogre::GLSL::GLSLProgram::CmdPreprocessorDefines
Command object for setting macro defines.
Definition: src/GLSL/include/OgreGLSLProgram.h:137
Ogre::GLSL::GLSLProgram::getOutputOperationType
virtual RenderOperation::OperationType getOutputOperationType(void) const
Returns the operation type that this geometry program will emit.
Definition: src/GLSL/include/OgreGLSLProgram.h:112
Ogre::GLSL::GLSLProgram::getGLHandle
GLhandleARB getGLHandle() const
Definition: src/GLSL/include/OgreGLSLProgram.h:80
Ogre::GLSL::GLSLProgram::getAttachedShaderNames
String getAttachedShaderNames() const
Definition: src/GLSL/include/OgreGLSLProgram.h:83
Ogre::RenderOperation::OperationType
OperationType
The rendering operation type to perform.
Definition: OgreRenderOperation.h:48
Ogre::vector
Definition: OgrePrerequisites.h:491
Ogre::ManualResourceLoader
Interface describing a manual resource loader.
Definition: OgreResource.h:514
Ogre::HighLevelGpuProgram
Abstract base class representing a high-level program (a vertex or fragment program).
Definition: OgreHighLevelGpuProgram.h:63
Ogre::GLSL::GLSLProgram::setColumnMajorMatrices
void setColumnMajorMatrices(bool columnMajor)
Sets whether matrix packing in column-major order.
Definition: src/GLSL/include/OgreGLSLProgram.h:101
Ogre::GLSL::GLSLProgram
Specialisation of HighLevelGpuProgram to provide support for OpenGL Shader Language (GLSL).
Definition: src/GLSL/include/OgreGLSLProgram.h:57
Ogre::GLSL::GLSLProgram::mColumnMajorMatrices
bool mColumnMajorMatrices
Matrix in column major pack format?
Definition: src/GLSL/include/OgreGLSLProgram.h:211
Ogre::GLSL::GLSLProgram::mAttachedShaderNames
String mAttachedShaderNames
Attached Shader names.
Definition: src/GLSL/include/OgreGLSLProgram.h:203

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