OGRE  1.9
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Plus/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 
33 
34 namespace Ogre {
57  {
58  public:
60  class CmdAttach : public ParamCommand
61  {
62  public:
63  String doGet(const void* target) const;
64  void doSet(void* target, const String& shaderNames);
65  };
66 
69  {
70  public:
71  String doGet(const void* target) const;
72  void doSet(void* target, const String& val);
73  };
76  {
77  public:
78  String doGet(const void* target) const;
79  void doSet(void* target, const String& val);
80  };
83  {
84  public:
85  String doGet(const void* target) const;
86  void doSet(void* target, const String& val);
87  };
90  {
91  public:
92  String doGet(const void* target) const;
93  void doSet(void* target, const String& val);
94  };
97  {
98  public:
99  String doGet(const void* target) const;
100  void doSet(void* target, const String& val);
101  };
106  { return mInputOperationType; }
110  { return mOutputOperationType; }
114  virtual int getMaxOutputVertices(void) const { return mMaxOutputVertices; }
115 
119  { mInputOperationType = operationType; }
123  { mOutputOperationType = operationType; }
127  virtual void setMaxOutputVertices(int maxOutputVertices)
128  { mMaxOutputVertices = maxOutputVertices; }
129 
130  GLSLProgram(ResourceManager* creator,
131  const String& name, ResourceHandle handle,
132  const String& group, bool isManual, ManualResourceLoader* loader);
133  ~GLSLProgram();
134 
135  GLuint getGLShaderHandle() const { return mGLShaderHandle; }
136  GLuint getGLProgramHandle() const { return mGLProgramHandle; }
137  void attachToProgramObject( const GLuint programObject );
138  void detachFromProgramObject( const GLuint programObject );
139  String getAttachedShaderNames() const { return mAttachedShaderNames; }
140 
142  bool getPassTransformStates(void) const;
143  bool getPassSurfaceAndLightStates(void) const;
144  bool getPassFogStates(void) const;
145 
147  void attachChildShader(const String& name);
148 
150  void setPreprocessorDefines(const String& defines) { mPreprocessorDefines = defines; }
152  const String& getPreprocessorDefines(void) const { return mPreprocessorDefines; }
153 
155  const String& getLanguage(void) const;
157  void setColumnMajorMatrices(bool columnMajor) { mColumnMajorMatrices = columnMajor; }
159  bool getColumnMajorMatrices(void) const { return mColumnMajorMatrices; }
160 
162  GpuProgramParametersSharedPtr createParameters(void);
163 
165  bool compile( const bool checkErrors = false);
166 
167  protected:
174 
177  void loadFromSource(void);
183  void createLowLevelImpl(void);
185  void unloadHighLevelImpl(void);
187  void unloadImpl(void);
188 
190  void populateParameterNames(GpuProgramParametersSharedPtr params);
192  void buildConstantDefinitions() const;
198  void checkAndFixInvalidDefaultPrecisionError( String &message );
199  private:
204  GLint mCompiled;
217  typedef GLSLProgramContainer::iterator GLSLProgramContainerIterator;
221  };
222 }
223 
224 #endif // __GLSLProgram_H__
String mAttachedShaderNames
Attached Shader names.
virtual void setMaxOutputVertices(int maxOutputVertices)
Set the maximum number of vertices that a single run of this geometry program can emit...
virtual void setOutputOperationType(RenderOperation::OperationType operationType)
Set the operation type that this geometry program will emit.
static CmdOutputOperationType msOutputOperationTypeCmd
Command object for setting the output operation type (geometry shader only)
Specialisation of HighLevelGpuProgram to provide support for OpenGL Shader Language (GLSL)...
virtual int getMaxOutputVertices(void) const
Returns the maximum number of vertices that this geometry program can output in a single run...
Interface describing a manual resource loader.
Definition: OgreResource.h:514
static CmdPreprocessorDefines msCmdPreprocessorDefines
virtual RenderOperation::OperationType getOutputOperationType(void) const
Returns the operation type that this geometry program will emit.
void setPreprocessorDefines(const String &defines)
Sets the preprocessor defines use to compile the program.
virtual RenderOperation::OperationType getInputOperationType(void) const
Returns the operation type that this geometry program expects to receive as input.
RenderOperation::OperationType mOutputOperationType
The output operation type for this (geometry) program.
Command object for setting the maximum output vertices (geometry shader only)
static CmdMaxOutputVertices msMaxOutputVerticesCmd
bool getColumnMajorMatrices(void) const
Gets whether matrix packed in column-major order.
GLint mCompiled
Flag indicating if shader object successfully compiled.
#define _OgreGL3PlusExport
unsigned long long int ResourceHandle
Definition: OgreResource.h:41
RenderOperation::OperationType mInputOperationType
The input operation type for this (geometry) program.
bool mColumnMajorMatrices
Matrix in column major pack format?
Command object for attaching another GLSL Program.
Command object for setting matrix packing in column-major order.
GLuint mGLShaderHandle
GL handle for shader object.
Command object for setting the input operation type (geometry shader only)
Defines a generic resource handler.
String mPreprocessorDefines
Preprocessor options.
_StringBase String
GLSLProgramContainer::iterator GLSLProgramContainerIterator
vector< GLSLProgram * >::type GLSLProgramContainer
Container of attached programs.
Abstract base class representing a high-level program (a vertex or fragment program).
static CmdInputOperationType msInputOperationTypeCmd
void setColumnMajorMatrices(bool columnMajor)
Sets whether matrix packing in column-major order.
int mMaxOutputVertices
The maximum amount of vertices that this (geometry) program can output.
Abstract class which is command object which gets/sets parameters.
static CmdColumnMajorMatrices msCmdColumnMajorMatrices
OperationType
The rendering operation type to perform.
const String & getPreprocessorDefines(void) const
Sets the preprocessor defines use to compile the program.
virtual void setInputOperationType(RenderOperation::OperationType operationType)
Sets the operation type that this geometry program expects to receive.