00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://www.ogre3d.org 00006 00007 Copyright (c) 2000-2013 Torus Knot Software Ltd 00008 Permission is hereby granted, free of charge, to any person obtaining a copy 00009 of this software and associated documentation files (the "Software"), to deal 00010 in the Software without restriction, including without limitation the rights 00011 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00012 copies of the Software, and to permit persons to whom the Software is 00013 furnished to do so, subject to the following conditions: 00014 00015 The above copyright notice and this permission notice shall be included in 00016 all copies or substantial portions of the Software. 00017 00018 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00019 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00020 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00021 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00022 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00023 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00024 THE SOFTWARE. 00025 ----------------------------------------------------------------------------- 00026 */ 00027 #ifndef _ShaderProgramWriterGLSL_ 00028 #define _ShaderProgramWriterGLSL_ 00029 00030 #include "OgreShaderProgramWriterManager.h" 00031 00032 namespace Ogre { 00033 namespace RTShader { 00034 00045 class _OgreRTSSExport GLSLProgramWriter : public ProgramWriter 00046 { 00047 // Interface. 00048 public: 00049 00052 GLSLProgramWriter(); 00053 00055 virtual ~GLSLProgramWriter(); 00056 00057 00061 virtual void writeSourceCode(std::ostream& os, Program* program); 00062 00066 virtual const String& getTargetLanguage() const { return TargetLanguage; } 00067 00068 static String TargetLanguage; 00069 00070 00071 // Protected methods. 00072 protected: 00073 00075 void initializeStringMaps(); 00076 00078 void writeLocalParameter(std::ostream& os, ParameterPtr parameter); 00079 00081 void writeForwardDeclarations(std::ostream& os, Program* program); 00082 00084 void writeInputParameters(std::ostream& os, Function* function, GpuProgramType gpuType); 00085 00087 void writeOutParameters(std::ostream& os, Function* function, GpuProgramType gpuType); 00088 00089 protected: 00090 typedef map<GpuConstantType, const char*>::type GpuConstTypeToStringMap; 00091 typedef map<Parameter::Semantic, const char*>::type ParamSemanticToStringMap; 00092 typedef map<Parameter::Content, const char*>::type ParamContentToStringMap; 00093 typedef map<String, String>::type StringMap; 00094 00095 // Attributes. 00096 protected: 00097 // Map between GPU constant type to string value. 00098 GpuConstTypeToStringMap mGpuConstTypeMap; 00099 // Map between parameter semantic to string value. 00100 ParamSemanticToStringMap mParamSemanticMap; 00101 00102 // Map parameter name to a new parameter name (sometime renaming is required to match names between vertex and fragment shader) 00103 StringMap mInputToGLStatesMap; 00104 // Map parameter content to vertex attributes 00105 ParamContentToStringMap mContentToPerVertexAttributes; 00106 // Holds the current glsl version 00107 int mGLSLVersion; 00108 // Holds the fragment input params 00109 StringVector mFragInputParams; 00110 }; 00111 00115 class _OgreRTSSExport ShaderProgramWriterGLSLFactory : public ProgramWriterFactory 00116 { 00117 public: 00118 ShaderProgramWriterGLSLFactory() : mLanguage("glsl") 00119 { 00120 } 00121 virtual ~ShaderProgramWriterGLSLFactory() {} 00122 00126 virtual const String& getTargetLanguage(void) const 00127 { 00128 return mLanguage; 00129 } 00130 00134 virtual ProgramWriter* create(void) 00135 { 00136 return OGRE_NEW GLSLProgramWriter(); 00137 } 00138 00139 private: 00140 String mLanguage; 00141 00142 }; 00143 00147 } 00148 } 00149 00150 #endif
Copyright © 2012 Torus Knot Software Ltd

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jul 27 2020 13:40:46