OgreShaderGLSLProgramWriter.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 _ShaderProgramWriterGLSL_
#define _ShaderProgramWriterGLSL_
#include "OgreShaderProgramWriterManager.h"
namespace Ogre {
namespace RTShader {
class _OgreRTSSExport GLSLProgramWriter : public ProgramWriter
{
// Interface.
public:
GLSLProgramWriter();
virtual ~GLSLProgramWriter();
virtual void writeSourceCode(std::ostream& os, Program* program);
virtual const String& getTargetLanguage() const { return TargetLanguage; }
static String TargetLanguage;
// Protected methods.
protected:
void initializeStringMaps();
void writeLocalParameter(std::ostream& os, ParameterPtr parameter);
void writeForwardDeclarations(std::ostream& os, Program* program);
void writeInputParameters(std::ostream& os, Function* function, GpuProgramType gpuType);
void writeOutParameters(std::ostream& os, Function* function, GpuProgramType gpuType);
protected:
typedef map<GpuConstantType, const char*>::type GpuConstTypeToStringMap;
typedef map<Parameter::Semantic, const char*>::type ParamSemanticToStringMap;
typedef map<Parameter::Content, const char*>::type ParamContentToStringMap;
typedef map<String, String>::type StringMap;
// Attributes.
protected:
// Map between GPU constant type to string value.
GpuConstTypeToStringMap mGpuConstTypeMap;
// Map between parameter semantic to string value.
ParamSemanticToStringMap mParamSemanticMap;
// Map parameter name to a new parameter name (sometime renaming is required to match names between vertex and fragment shader)
StringMap mInputToGLStatesMap;
// Map parameter content to vertex attributes
ParamContentToStringMap mContentToPerVertexAttributes;
// Holds the current glsl version
int mGLSLVersion;
// Holds the fragment input params
StringVector mFragInputParams;
};
class _OgreRTSSExport ShaderProgramWriterGLSLFactory : public ProgramWriterFactory
{
public:
ShaderProgramWriterGLSLFactory() : mLanguage("glsl")
{
}
virtual ~ShaderProgramWriterGLSLFactory() {}
virtual const String& getTargetLanguage(void) const
{
return mLanguage;
}
virtual ProgramWriter* create(void)
{
return OGRE_NEW GLSLProgramWriter();
}
private:
String mLanguage;
};
}
}
#endif
Ogre::RTShader::ProgramWriterFactory
Interface definition for factories of ShaderProgramWriter.
Definition: OgreShaderProgramWriterManager.h:46
Ogre::RTShader::GLSLProgramWriter::StringMap
map< String, String >::type StringMap
Definition: OgreShaderGLSLProgramWriter.h:93
Ogre::RTShader::GLSLProgramWriter::mGpuConstTypeMap
GpuConstTypeToStringMap mGpuConstTypeMap
Definition: OgreShaderGLSLProgramWriter.h:98
Ogre::RTShader::GLSLProgramWriter::mInputToGLStatesMap
StringMap mInputToGLStatesMap
Definition: OgreShaderGLSLProgramWriter.h:103
Ogre::StringVector
vector< String >::type StringVector
Definition: OgreStringVector.h:45
OGRE_NEW
#define OGRE_NEW
Definition: OgreMemoryAllocatorConfig.h:473
Ogre::RTShader::GLSLProgramWriter::TargetLanguage
static String TargetLanguage
Definition: OgreShaderGLSLProgramWriter.h:68
Ogre::RTShader::ProgramWriter
Base class interface for shader program writers.
Definition: OgreShaderProgramWriter.h:52
Ogre::RTShader::GLSLProgramWriter::getTargetLanguage
virtual const String & getTargetLanguage() const
Definition: OgreShaderGLSLProgramWriter.h:66
Ogre::RTShader::ShaderProgramWriterGLSLFactory::getTargetLanguage
virtual const String & getTargetLanguage(void) const
Definition: OgreShaderGLSLProgramWriter.h:126
Ogre::RTShader::ShaderProgramWriterGLSLFactory::create
virtual ProgramWriter * create(void)
Definition: OgreShaderGLSLProgramWriter.h:134
Ogre::RTShader::ShaderProgramWriterGLSLFactory::ShaderProgramWriterGLSLFactory
ShaderProgramWriterGLSLFactory()
Definition: OgreShaderGLSLProgramWriter.h:118
Ogre::RTShader::Program
A class that represents a shader based program.
Definition: OgreShaderProgram.h:50
Ogre::RTShader::GLSLProgramWriter::GpuConstTypeToStringMap
map< GpuConstantType, const char * >::type GpuConstTypeToStringMap
Definition: OgreShaderGLSLProgramWriter.h:90
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::RTShader::ShaderProgramWriterGLSLFactory::mLanguage
String mLanguage
Definition: OgreShaderGLSLProgramWriter.h:140
Ogre::RTShader::GLSLProgramWriter::ParamContentToStringMap
map< Parameter::Content, const char * >::type ParamContentToStringMap
Definition: OgreShaderGLSLProgramWriter.h:92
OgreShaderProgramWriterManager.h
Ogre::GpuProgramType
GpuProgramType
Enumerates the types of programs which can run on the GPU.
Definition: OgreGpuProgram.h:50
Ogre::RTShader::ShaderProgramWriterGLSLFactory
GLSL program writer factory implementation.
Definition: OgreShaderGLSLProgramWriter.h:115
_OgreRTSSExport
#define _OgreRTSSExport
Definition: OgreShaderPrerequisites.h:108
Ogre::RTShader::GLSLProgramWriter::mGLSLVersion
int mGLSLVersion
Definition: OgreShaderGLSLProgramWriter.h:107
Ogre::RTShader::GLSLProgramWriter::mParamSemanticMap
ParamSemanticToStringMap mParamSemanticMap
Definition: OgreShaderGLSLProgramWriter.h:100
Ogre
Definition: OgreAndroidLogListener.h:34
Ogre::RTShader::Function
A class that represents a shader based program function.
Definition: OgreShaderFunction.h:46
Ogre::SharedPtr< Parameter >
Ogre::RTShader::GLSLProgramWriter::mFragInputParams
StringVector mFragInputParams
Definition: OgreShaderGLSLProgramWriter.h:109
Ogre::RTShader::ShaderProgramWriterGLSLFactory::~ShaderProgramWriterGLSLFactory
virtual ~ShaderProgramWriterGLSLFactory()
Definition: OgreShaderGLSLProgramWriter.h:121
Ogre::map
Definition: OgrePrerequisites.h:533
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::GLSLProgramWriter::mContentToPerVertexAttributes
ParamContentToStringMap mContentToPerVertexAttributes
Definition: OgreShaderGLSLProgramWriter.h:105

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