OgreShaderHLSLProgramWriter.h
Go to the documentation of this file.
/*
-----------------------------------------------------------------------------
This source file is part of OGRE
(Object-oriented Graphics Rendering Engine)
For the latest info, see http://www.ogre3d.org/
Copyright (c) 2000-2013 Torus Knot Software Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-----------------------------------------------------------------------------
*/
#ifndef __ShaderProgramWriterHLSL_H__
#define __ShaderProgramWriterHLSL_H__
#include "OgreShaderProgramWriterManager.h"
namespace Ogre {
namespace RTShader {
class _OgreRTSSExport HLSLProgramWriter : public ProgramWriter
{
// Interface.
public:
HLSLProgramWriter();
virtual ~HLSLProgramWriter();
virtual void writeSourceCode(std::ostream& os, Program* program);
virtual const String& getTargetLanguage() const { return TargetLanguage; }
static String TargetLanguage;
// Protected methods.
protected:
void initializeStringMaps();
void writeProgramDependencies(std::ostream& os, Program* program);
void writeUniformParameter(std::ostream& os, UniformParameterPtr parameter);
void writeFunctionParameter(std::ostream& os, ParameterPtr parameter, const char* forcedSemantic);
void writeLocalParameter(std::ostream& os, ParameterPtr parameter);
void writeFunctionDeclaration(std::ostream& os, Function* function);
void writeAtomInstance(std::ostream& os, FunctionAtom* atom);
protected:
typedef map<GpuConstantType, const char*>::type GpuConstTypeToStringMap;
typedef map<Parameter::Semantic, const char*>::type ParamSemanticToStringMap;
// Attributes.
protected:
// Map between GPU constant type to string value.
GpuConstTypeToStringMap mGpuConstTypeMap;
// Map between parameter semantic to string value.
ParamSemanticToStringMap mParamSemanticMap;
};
class _OgreRTSSExport ShaderProgramWriterHLSLFactory : public ProgramWriterFactory
{
public:
ShaderProgramWriterHLSLFactory()
{
mLanguage = "hlsl";
}
virtual ~ShaderProgramWriterHLSLFactory() {}
virtual const String& getTargetLanguage(void) const
{
return mLanguage;
}
virtual ProgramWriter* create(void)
{
return OGRE_NEW HLSLProgramWriter();
}
private:
String mLanguage;
};
}
}
#endif
Ogre::RTShader::ProgramWriterFactory
Interface definition for factories of ShaderProgramWriter.
Definition: OgreShaderProgramWriterManager.h:46
Ogre::RTShader::HLSLProgramWriter::TargetLanguage
static String TargetLanguage
Definition: OgreShaderHLSLProgramWriter.h:69
Ogre::RTShader::FunctionAtom
A class that represents an atomic code section of shader based program function.
Definition: OgreShaderFunctionAtom.h:48
Ogre::RTShader::HLSLProgramWriter::GpuConstTypeToStringMap
map< GpuConstantType, const char * >::type GpuConstTypeToStringMap
Definition: OgreShaderHLSLProgramWriter.h:96
Ogre::RTShader::ShaderProgramWriterHLSLFactory
HLSL program writer factory implementation.
Definition: OgreShaderHLSLProgramWriter.h:110
Ogre::RTShader::HLSLProgramWriter
HLSL target language writer implementation.
Definition: OgreShaderHLSLProgramWriter.h:46
Ogre::RTShader::ShaderProgramWriterHLSLFactory::getTargetLanguage
virtual const String & getTargetLanguage(void) const
Definition: OgreShaderHLSLProgramWriter.h:122
Ogre::RTShader::HLSLProgramWriter::mGpuConstTypeMap
GpuConstTypeToStringMap mGpuConstTypeMap
Definition: OgreShaderHLSLProgramWriter.h:102
OGRE_NEW
#define OGRE_NEW
Definition: OgreMemoryAllocatorConfig.h:473
Ogre::RTShader::HLSLProgramWriter::mParamSemanticMap
ParamSemanticToStringMap mParamSemanticMap
Definition: OgreShaderHLSLProgramWriter.h:104
Ogre::RTShader::ProgramWriter
Base class interface for shader program writers.
Definition: OgreShaderProgramWriter.h:52
Ogre::RTShader::Program
A class that represents a shader based program.
Definition: OgreShaderProgram.h:50
Ogre::RTShader::ShaderProgramWriterHLSLFactory::create
virtual ProgramWriter * create(void)
Definition: OgreShaderHLSLProgramWriter.h:130
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::RTShader::HLSLProgramWriter::ParamSemanticToStringMap
map< Parameter::Semantic, const char * >::type ParamSemanticToStringMap
Definition: OgreShaderHLSLProgramWriter.h:97
OgreShaderProgramWriterManager.h
_OgreRTSSExport
#define _OgreRTSSExport
Definition: OgreShaderPrerequisites.h:108
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::RTShader::Function
A class that represents a shader based program function.
Definition: OgreShaderFunction.h:46
Ogre::SharedPtr
Reference-counted shared pointer, used for objects where implicit destruction is required.
Definition: OgrePrerequisites.h:310
Ogre::RTShader::HLSLProgramWriter::getTargetLanguage
virtual const String & getTargetLanguage() const
Definition: OgreShaderHLSLProgramWriter.h:67
Ogre::map
Definition: OgrePrerequisites.h:533
Ogre::RTShader::ShaderProgramWriterHLSLFactory::ShaderProgramWriterHLSLFactory
ShaderProgramWriterHLSLFactory()
Definition: OgreShaderHLSLProgramWriter.h:113
Ogre::RTShader::ShaderProgramWriterHLSLFactory::mLanguage
String mLanguage
Definition: OgreShaderHLSLProgramWriter.h:136
Ogre::RTShader::ShaderProgramWriterHLSLFactory::~ShaderProgramWriterHLSLFactory
virtual ~ShaderProgramWriterHLSLFactory()
Definition: OgreShaderHLSLProgramWriter.h:117

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