OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreShaderHLSLProgramWriter.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 __ShaderProgramWriterHLSL_H__
29 #define __ShaderProgramWriterHLSL_H__
30 
33 #include "OgreShaderParameter.h"
34 
35 namespace Ogre {
36  namespace RTShader {
37 
38  class Function;
39  class FunctionAtom;
40  class Program;
41 
53 {
54 
55  // Interface.
56 public:
57 
61 
63  virtual ~HLSLProgramWriter();
64 
68  virtual void writeSourceCode(std::ostream& os, Program* program);
69 
73  virtual const String& getTargetLanguage() const { return TargetLanguage; }
74 
76 
77  // Protected methods.
78 protected:
79 
81  void initializeStringMaps();
82 
84  void writeProgramDependencies(std::ostream& os, Program* program);
85 
87  void writeUniformParameter(std::ostream& os, UniformParameterPtr parameter);
88 
90  void writeFunctionParameter(std::ostream& os, ParameterPtr parameter, const char* forcedSemantic);
91 
93  void writeLocalParameter(std::ostream& os, ParameterPtr parameter);
94 
96  void writeFunctionDeclaration(std::ostream& os, Function* function);
97 
99  void writeAtomInstance(std::ostream& os, FunctionAtom* atom);
100 
101 protected:
104 
105  // Attributes.
106 protected:
107  // Map between GPU constant type to string value.
109  // Map between GPU constant type v4 to string value.
110  //TODO : add abstraction per version
112  // Map between parameter semantic to string value.
114 };
115 
120 {
121 public:
122  ShaderProgramWriterHLSLFactory() : mLanguage("hlsl") {}
124 
128  virtual const String& getTargetLanguage(void) const
129  {
130  return mLanguage;
131  }
132 
136  virtual ProgramWriter* create(void)
137  {
138  return OGRE_NEW HLSLProgramWriter();
139  }
140 
141 private:
143 
144 };
145 
146 
149 }
150 }
151 
152 #endif
Interface definition for factories of ShaderProgramWriter.
#define _OgreRTSSExport
virtual const String & getTargetLanguage() const
map< GpuConstantType, const char * >::type GpuConstTypeToStringMap
A class that represents a shader based program function.
Base class interface for shader program writers.
HLSL program writer factory implementation.
A class that represents an atomic code section of shader based program function.
A class that represents a shader based program.
#define OGRE_NEW
Reference-counted shared pointer, used for objects where implicit destruction is required.
_StringBase String
Definition: OgreCommon.h:53
map< Parameter::Semantic, const char * >::type ParamSemanticToStringMap
HLSL target language writer implementation.