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-2013 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 
31 
32 namespace Ogre {
33 namespace RTShader {
34 
46 {
47  // Interface.
48 public:
49 
53 
55  virtual ~GLSLProgramWriter();
56 
57 
61  virtual void writeSourceCode(std::ostream& os, Program* program);
62 
66  virtual const String& getTargetLanguage() const { return TargetLanguage; }
67 
69 
70 
71  // Protected methods.
72 protected:
73 
76 
78  void writeLocalParameter(std::ostream& os, ParameterPtr parameter);
79 
81  void writeForwardDeclarations(std::ostream& os, Program* program);
82 
84  void writeInputParameters(std::ostream& os, Function* function, GpuProgramType gpuType);
85 
87  void writeOutParameters(std::ostream& os, Function* function, GpuProgramType gpuType);
88 
89 protected:
94 
95  // Attributes.
96 protected:
97  // Map between GPU constant type to string value.
99  // Map between parameter semantic to string value.
101 
102  // Map parameter name to a new parameter name (sometime renaming is required to match names between vertex and fragment shader)
104  // Map parameter content to vertex attributes
106  // Holds the current glsl version
108  // Holds the fragment input params
110 };
111 
116 {
117 public:
118  ShaderProgramWriterGLSLFactory() : mLanguage("glsl")
119  {
120  }
122 
126  virtual const String& getTargetLanguage(void) const
127  {
128  return mLanguage;
129  }
130 
134  virtual ProgramWriter* create(void)
135  {
136  return OGRE_NEW GLSLProgramWriter();
137  }
138 
139 private:
141 
142 };
143 
147 }
148 }
149 
150 #endif
#define _OgreRTSSExport
A class that represents a shader based program function.
GLSL target language writer implementation.
map< Parameter::Content, const char * >::type ParamContentToStringMap
void writeForwardDeclarations(std::ostream &os, Program *program)
Write forward declarations.
void initializeStringMaps()
Initialize string maps.
map< GpuConstantType, const char * >::type GpuConstTypeToStringMap
void writeOutParameters(std::ostream &os, Function *function, GpuProgramType gpuType)
Write the output params of the function.
void writeInputParameters(std::ostream &os, Function *function, GpuProgramType gpuType)
Write the input params of the function.
GLSLProgramWriter()
Class constructor.
virtual const String & getTargetLanguage() const
void writeLocalParameter(std::ostream &os, ParameterPtr parameter)
Write a local parameter.
ParamContentToStringMap mContentToPerVertexAttributes
virtual void writeSourceCode(std::ostream &os, Program *program)
virtual ~GLSLProgramWriter()
Class destructor.
map< Parameter::Semantic, const char * >::type ParamSemanticToStringMap
Interface definition for factories of ShaderProgramWriter.
Base class interface for shader program writers.
A class that represents a shader based program.
GLSL program writer factory implementation.
vector< String >::type StringVector
#define OGRE_NEW
GpuProgramType
Enumerates the types of programs which can run on the GPU.
_StringBase String

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.