OGRE  1.9.0
OgreShaderGLSLProgramWriter.h
Go to the documentation of this file.
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4(Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org
6
7Copyright (c) 2000-2014 Torus Knot Software Ltd
8Permission is hereby granted, free of charge, to any person obtaining a copy
9of this software and associated documentation files (the "Software"), to deal
10in the Software without restriction, including without limitation the rights
11to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12copies of the Software, and to permit persons to whom the Software is
13furnished to do so, subject to the following conditions:
14
15The above copyright notice and this permission notice shall be included in
16all copies or substantial portions of the Software.
17
18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24THE SOFTWARE.
25-----------------------------------------------------------------------------
26*/
27#ifndef _ShaderProgramWriterGLSL_
28#define _ShaderProgramWriterGLSL_
29
31
32namespace Ogre {
33namespace RTShader {
34
46{
47 // Interface.
48public:
49
53
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.
72protected:
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
89protected:
94
95 // Attributes.
96protected:
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{
117public:
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 {
137 }
138
139private:
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, constchar * >::type ParamContentToStringMap
void writeForwardDeclarations(std::ostream &os, Program *program)
Write forward declarations.
void initializeStringMaps()
Initialize string maps.
void writeOutParameters(std::ostream &os, Function *function, GpuProgramType gpuType)
Write the output params of the function.
virtual const String & getTargetLanguage() const
void writeInputParameters(std::ostream &os, Function *function, GpuProgramType gpuType)
Write the input params of the function.
GLSLProgramWriter()
Class constructor.
map< Parameter::Semantic, constchar * >::type ParamSemanticToStringMap
void writeLocalParameter(std::ostream &os, ParameterPtr parameter)
Write a local parameter.
map< GpuConstantType, constchar * >::type GpuConstTypeToStringMap
ParamContentToStringMap mContentToPerVertexAttributes
virtual void writeSourceCode(std::ostream &os, Program *program)
virtual ~GLSLProgramWriter()
Class destructor.
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
std::map< K, V, P, A > type