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__
const String & getPreprocessorDefines(void) const
Sets the preprocessor defines use to compile the program.
String mAttachedShaderNames
Attached Shader names.
Command object for setting the maximum output vertices (geometry shader only)
RenderOperation::OperationType mInputOperationType
The input operation type for this (geometry) program.
Specialisation of HighLevelGpuProgram to provide support for OpenGL Shader Language (GLSL)...
static CmdOutputOperationType msOutputOperationTypeCmd
Abstract base class representing a high-level program (a vertex or fragment program).
Interface describing a manual resource loader.
Definition: OgreResource.h:514
unsigned long long int ResourceHandle
Definition: OgreResource.h:41
Command object for setting the output operation type (geometry shader only)
void setPreprocessorDefines(const String &defines)
Sets the preprocessor defines use to compile the program.
bool mColumnMajorMatrices
Matrix in column major pack format?
Command object for setting the input operation type (geometry shader only)
#define _OgreGLExport
virtual void setMaxOutputVertices(int maxOutputVertices)
Set the maximum number of vertices that a single run of this geometry program can emit...
_StringBase String
GLSLProgramContainer::iterator GLSLProgramContainerIterator
OperationType
The rendering operation type to perform.
RenderOperation::OperationType mOutputOperationType
The output operation type for this (geometry) program.
static CmdInputOperationType msInputOperationTypeCmd
virtual void setOutputOperationType(RenderOperation::OperationType operationType)
Set the operation type that this geometry program will emit.
Defines a generic resource handler.
virtual RenderOperation::OperationType getOutputOperationType(void) const
Returns the operation type that this geometry program will emit.
Command object for setting matrix packing in column-major order.
GLhandleARB mGLHandle
GL handle for shader object.
vector< GLSLProgram * >::type GLSLProgramContainer
Container of attached programs.
int mMaxOutputVertices
The maximum amount of vertices that this (geometry) program can output.
bool getColumnMajorMatrices(void) const
Gets whether matrix packed in column-major order.
virtual RenderOperation::OperationType getInputOperationType(void) const
Returns the operation type that this geometry program expects to receive as input.
static CmdPreprocessorDefines msCmdPreprocessorDefines
GLint mCompiled
Flag indicating if shader object successfully compiled.
Command object for attaching another GLSL Program.
static CmdMaxOutputVertices msMaxOutputVerticesCmd
void setColumnMajorMatrices(bool columnMajor)
Sets whether matrix packing in column-major order.
Abstract class which is command object which gets/sets parameters.
String mPreprocessorDefines
Preprocessor options.
virtual void setInputOperationType(RenderOperation::OperationType operationType)
Sets the operation type that this geometry program expects to receive.
virtual int getMaxOutputVertices(void) const
Returns the maximum number of vertices that this geometry program can output in a single run...
static CmdColumnMajorMatrices msCmdColumnMajorMatrices

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 Mar 18 2014 19:15:25