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 
75  void initializeStringMaps();
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
Ogre::RTShader::GLSLProgramWriter::mFragInputParams
StringVector mFragInputParams
Definition: OgreShaderGLSLProgramWriter.h:109
Ogre::RTShader::GLSLProgramWriter::mContentToPerVertexAttributes
ParamContentToStringMap mContentToPerVertexAttributes
Definition: OgreShaderGLSLProgramWriter.h:105
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::RTShader::ShaderProgramWriterGLSLFactory::create
virtual ProgramWriter * create(void)
Definition: OgreShaderGLSLProgramWriter.h:134
Ogre::map
Definition: OgrePrerequisites.h:533
Ogre::RTShader::ShaderProgramWriterGLSLFactory
GLSL program writer factory implementation.
Definition: OgreShaderGLSLProgramWriter.h:115
Ogre::StringVector
vector< String >::type StringVector
Definition: OgreStringVector.h:45
OgreShaderProgramWriterManager.h
Ogre::RTShader::GLSLProgramWriter::ParamContentToStringMap
map< Parameter::Content, const char * >::type ParamContentToStringMap
Definition: OgreShaderGLSLProgramWriter.h:92
Ogre::RTShader::GLSLProgramWriter::mParamSemanticMap
ParamSemanticToStringMap mParamSemanticMap
Definition: OgreShaderGLSLProgramWriter.h:100
Ogre::RTShader::GLSLProgramWriter::getTargetLanguage
virtual const String & getTargetLanguage() const
Definition: OgreShaderGLSLProgramWriter.h:66
Ogre::RTShader::GLSLProgramWriter::mGLSLVersion
int mGLSLVersion
Definition: OgreShaderGLSLProgramWriter.h:107
Ogre::RTShader::ShaderProgramWriterGLSLFactory::getTargetLanguage
virtual const String & getTargetLanguage(void) const
Definition: OgreShaderGLSLProgramWriter.h:126
Ogre::RTShader::ProgramWriter
Base class interface for shader program writers.
Definition: OgreShaderProgramWriter.h:52
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::GpuProgramType
GpuProgramType
Enumerates the types of programs which can run on the GPU.
Definition: OgreGpuProgram.h:50
Ogre::RTShader::GLSLProgramWriter::TargetLanguage
static String TargetLanguage
Definition: OgreShaderGLSLProgramWriter.h:68
Ogre::RTShader::GLSLProgramWriter::mInputToGLStatesMap
StringMap mInputToGLStatesMap
Definition: OgreShaderGLSLProgramWriter.h:103
Ogre::RTShader::Program
A class that represents a shader based program.
Definition: OgreShaderProgram.h:50
Ogre::RTShader::ShaderProgramWriterGLSLFactory::mLanguage
String mLanguage
Definition: OgreShaderGLSLProgramWriter.h:140
Ogre::RTShader::ShaderProgramWriterGLSLFactory::ShaderProgramWriterGLSLFactory
ShaderProgramWriterGLSLFactory()
Definition: OgreShaderGLSLProgramWriter.h:118
Ogre::RTShader::GLSLProgramWriter::mGpuConstTypeMap
GpuConstTypeToStringMap mGpuConstTypeMap
Definition: OgreShaderGLSLProgramWriter.h:98
Ogre::SharedPtr< Parameter >
Ogre::RTShader::GLSLProgramWriter::GpuConstTypeToStringMap
map< GpuConstantType, const char * >::type GpuConstTypeToStringMap
Definition: OgreShaderGLSLProgramWriter.h:90
Ogre::RTShader::GLSLProgramWriter
GLSL target language writer implementation.
Definition: OgreShaderGLSLProgramWriter.h:45
Ogre::RTShader::GLSLProgramWriter::ParamSemanticToStringMap
map< Parameter::Semantic, const char * >::type ParamSemanticToStringMap
Definition: OgreShaderGLSLProgramWriter.h:91
Ogre::RTShader::ProgramWriterFactory
Interface definition for factories of ShaderProgramWriter.
Definition: OgreShaderProgramWriterManager.h:46
OGRE_NEW
#define OGRE_NEW
Definition: OgreMemoryAllocatorConfig.h:473
Ogre::RTShader::GLSLProgramWriter::StringMap
map< String, String >::type StringMap
Definition: OgreShaderGLSLProgramWriter.h:93
Ogre::RTShader::Function
A class that represents a shader based program function.
Definition: OgreShaderFunction.h:46
Ogre::RTShader::ShaderProgramWriterGLSLFactory::~ShaderProgramWriterGLSLFactory
virtual ~ShaderProgramWriterGLSLFactory()
Definition: OgreShaderGLSLProgramWriter.h:121
_OgreRTSSExport
#define _OgreRTSSExport
Definition: OgreShaderPrerequisites.h:108

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