OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreShaderGLSLProgramWriter.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 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14 
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17 
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 THE SOFTWARE.
25 -----------------------------------------------------------------------------
26 */
27 #ifndef _ShaderProgramWriterGLSL_
28 #define _ShaderProgramWriterGLSL_
29 
32 #include "OgreShaderParameter.h"
33 #include "OgreStringVector.h"
34 
35 namespace Ogre {
36 namespace RTShader {
37 
38  class Function;
39  class Program;
40 
52 {
53  // Interface.
54 public:
55 
59 
61  virtual ~GLSLProgramWriter();
62 
63 
67  virtual void writeSourceCode(std::ostream& os, Program* program);
68 
72  virtual const String& getTargetLanguage() const { return TargetLanguage; }
73 
75 
76 
77  // Protected methods.
78 protected:
79 
81  void initializeStringMaps();
82 
84  void writeLocalParameter(std::ostream& os, ParameterPtr parameter);
85 
87  void writeForwardDeclarations(std::ostream& os, Program* program);
88 
90  void writeInputParameters(std::ostream& os, Function* function, GpuProgramType gpuType);
91 
93  void writeOutParameters(std::ostream& os, Function* function, GpuProgramType gpuType);
94 
95 protected:
100 
101  // Attributes.
102 protected:
103  // Map between GPU constant type to string value.
105  // Map between parameter semantic to string value.
107 
108  // Map parameter name to a new parameter name (sometime renaming is required to match names between vertex and fragment shader)
110  // Map parameter content to vertex attributes
112  // Holds the current glsl version
114  // Holds the fragment input params
116 };
117 
122 {
123 public:
124  ShaderProgramWriterGLSLFactory() : mLanguage("glsl")
125  {
126  }
128 
132  virtual const String& getTargetLanguage(void) const
133  {
134  return mLanguage;
135  }
136 
140  virtual ProgramWriter* create(void)
141  {
142  return OGRE_NEW GLSLProgramWriter();
143  }
144 
145 private:
147 
148 };
149 
153 }
154 }
155 
156 #endif
map< GpuConstantType, const char * >::type GpuConstTypeToStringMap
GpuProgramType
Enumerates the types of programs which can run on the GPU.
Interface definition for factories of ShaderProgramWriter.
#define _OgreRTSSExport
map< Parameter::Content, const char * >::type ParamContentToStringMap
A class that represents a shader based program function.
Base class interface for shader program writers.
map< Parameter::Semantic, const char * >::type ParamSemanticToStringMap
GLSL program writer factory implementation.
vector< String >::type StringVector
virtual const String & getTargetLanguage() const
A class that represents a shader based program.
#define OGRE_NEW
ParamContentToStringMap mContentToPerVertexAttributes
_StringBase String
Definition: OgreCommon.h:53
GLSL target language writer implementation.