OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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-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 __GLSLProgram_H__
29 #define __GLSLProgram_H__
30 
31 #include "OgreGLPrerequisites.h"
33 #include "OgreRenderOperation.h"
34 
35 namespace Ogre {
36  namespace GLSL {
59  {
60  public:
62  class CmdAttach : public ParamCommand
63  {
64  public:
65  String doGet(const void* target) const;
66  void doSet(void* target, const String& shaderNames);
67  };
70  {
71  public:
72  String doGet(const void* target) const;
73  void doSet(void* target, const String& val);
74  };
75 
76  GLSLProgram(ResourceManager* creator,
77  const String& name, ResourceHandle handle,
78  const String& group, bool isManual, ManualResourceLoader* loader);
79  ~GLSLProgram();
80 
81  GLhandleARB getGLHandle() const { return mGLHandle; }
82  void attachToProgramObject( const GLhandleARB programObject );
83  void detachFromProgramObject( const GLhandleARB programObject );
84  String getAttachedShaderNames() const { return mAttachedShaderNames; }
85 
87  bool getPassTransformStates(void) const;
88  bool getPassSurfaceAndLightStates(void) const;
89 
91  void attachChildShader(const String& name);
92 
94  void setPreprocessorDefines(const String& defines) { mPreprocessorDefines = defines; }
96  const String& getPreprocessorDefines(void) const { return mPreprocessorDefines; }
97 
99  const String& getLanguage(void) const;
100 
102  void setColumnMajorMatrices(bool columnMajor) { mColumnMajorMatrices = columnMajor; }
104  bool getColumnMajorMatrices(void) const { return mColumnMajorMatrices; }
105 
110  { return mInputOperationType; }
114  { return mOutputOperationType; }
118  virtual int getMaxOutputVertices(void) const { return mMaxOutputVertices; }
119 
123  { mInputOperationType = operationType; }
127  { mOutputOperationType = operationType; }
131  virtual void setMaxOutputVertices(int maxOutputVertices)
132  { mMaxOutputVertices = maxOutputVertices; }
133 
135  bool compile( const bool checkErrors = true);
136 
139  {
140  public:
141  String doGet(const void* target) const;
142  void doSet(void* target, const String& val);
143  };
146  {
147  public:
148  String doGet(const void* target) const;
149  void doSet(void* target, const String& val);
150  };
153  {
154  public:
155  String doGet(const void* target) const;
156  void doSet(void* target, const String& val);
157  };
160  {
161  public:
162  String doGet(const void* target) const;
163  void doSet(void* target, const String& val);
164  };
165  protected:
172 
175  void loadFromSource(void);
181  void createLowLevelImpl(void);
183  void unloadHighLevelImpl(void);
185  void unloadImpl(void);
186 
188  void populateParameterNames(GpuProgramParametersSharedPtr params);
190  void buildConstantDefinitions() const;
191 
192  private:
194  GLhandleARB mGLHandle;
196  GLint mCompiled;
209  typedef GLSLProgramContainer::iterator GLSLProgramContainerIterator;
213 
214  };
215  }
216 }
217 
218 #endif // __GLSLProgram_H__
virtual int getMaxOutputVertices(void) const
Returns the maximum number of vertices that this geometry program can output in a single run...
void setColumnMajorMatrices(bool columnMajor)
Sets whether matrix packing in column-major order.
Command object for setting matrix packing in column-major order.
GLhandleARB mGLHandle
GL handle for shader object.
void setPreprocessorDefines(const String &defines)
Sets the preprocessor defines use to compile the program.
Command object for setting the input operation type (geometry shader only)
bool mColumnMajorMatrices
Matrix in column major pack format?
Interface describing a manual resource loader.
Definition: OgreResource.h:498
virtual void setInputOperationType(RenderOperation::OperationType operationType)
Sets the operation type that this geometry program expects to receive.
static CmdPreprocessorDefines msCmdPreprocessorDefines
RenderOperation::OperationType mOutputOperationType
The output operation type for this (geometry) program.
#define _OgreGLExport
vector< GLSLProgram * >::type GLSLProgramContainer
Container of attached programs.
Command object for setting the output operation type (geometry shader only)
static CmdInputOperationType msInputOperationTypeCmd
virtual RenderOperation::OperationType getInputOperationType(void) const
Returns the operation type that this geometry program expects to receive as input.
Command object for attaching another GLSL Program.
virtual RenderOperation::OperationType getOutputOperationType(void) const
Returns the operation type that this geometry program will emit.
static CmdMaxOutputVertices msMaxOutputVerticesCmd
virtual void setMaxOutputVertices(int maxOutputVertices)
Set the maximum number of vertices that a single run of this geometry program can emit...
static CmdColumnMajorMatrices msCmdColumnMajorMatrices
String mAttachedShaderNames
Attached Shader names.
Command object for setting the maximum output vertices (geometry shader only)
bool getColumnMajorMatrices(void) const
Gets whether matrix packed in column-major order.
unsigned long long int ResourceHandle
Definition: OgreResource.h:39
Specialisation of HighLevelGpuProgram to provide support for OpenGL Shader Language (GLSL)...
int mMaxOutputVertices
The maximum amount of vertices that this (geometry) program can output.
RenderOperation::OperationType mInputOperationType
The input operation type for this (geometry) program.
static CmdOutputOperationType msOutputOperationTypeCmd
Defines a generic resource handler.
_StringBase String
Definition: OgreCommon.h:53
GLint mCompiled
Flag indicating if shader object successfully compiled.
Abstract base class representing a high-level program (a vertex or fragment program).
const String & getPreprocessorDefines(void) const
Sets the preprocessor defines use to compile the program.
GLSLProgramContainer::iterator GLSLProgramContainerIterator
String mPreprocessorDefines
Preprocessor options.
Abstract class which is command object which gets/sets parameters.
OperationType
The rendering operation type to perform.
virtual void setOutputOperationType(RenderOperation::OperationType operationType)
Set the operation type that this geometry program will emit.