00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://www.stevestreeting.com/ogre/ 00006 00007 Copyright (c) 2000-2005 The OGRE Team 00008 Also see acknowledgements in Readme.html 00009 00010 This program is free software; you can redistribute it and/or modify it under 00011 the terms of the GNU General Public License as published by the Free Software 00012 Foundation; either version 2 of the License, or (at your option) any later 00013 version. 00014 00015 This program is distributed in the hope that it will be useful, but WITHOUT 00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00017 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License along with 00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00022 http://www.gnu.org/copyleft/gpl.html. 00023 ----------------------------------------------------------------------------- 00024 */ 00025 00026 #ifndef __CompositorScriptScompiler_H__ 00027 #define __CompositorScriptScompiler_H__ 00028 00029 #include "OgrePrerequisites.h" 00030 #include "OgreCompiler2Pass.h" 00031 #include "OgreCompositor.h" 00032 #include "OgreRenderSystem.h" 00033 00034 00035 namespace Ogre { 00036 00038 class _OgreExport CompositorScriptCompiler : public Compiler2Pass 00039 { 00040 00041 public: 00042 CompositorScriptCompiler(void); 00043 ~CompositorScriptCompiler(void); 00044 00047 virtual const String& getClientBNFGrammer(void) { return compositorScript_BNF; } 00048 00051 virtual const String& getClientGrammerName(void) const { static const String grammerName("Compositor Script"); return grammerName; } 00059 void parseScript(DataStreamPtr& stream, const String& groupName) 00060 { 00061 mScriptContext.groupName = groupName; 00062 Compiler2Pass::compile(stream->getAsString(), stream->getName()); 00063 } 00064 00065 protected: 00066 // Token ID enumeration 00067 enum TokenID { 00068 // Terminal Tokens section 00069 ID_UNKOWN = 0, ID_OPENBRACE, ID_CLOSEBRACE, 00070 // Top level 00071 ID_COMPOSITOR, 00072 // Techniques 00073 ID_TECHNIQUE, ID_TEXTURE, ID_TARGET_WIDTH, ID_TARGET_HEIGHT, 00074 ID_PF_A8R8G8B8, ID_PF_R8G8B8A8, ID_PF_R8G8B8, 00075 ID_PF_FLOAT16_R, ID_PF_FLOAT16_RGB, ID_PF_FLOAT16_RGBA, 00076 ID_PF_FLOAT32_R, ID_PF_FLOAT32_RGB, ID_PF_FLOAT32_RGBA, 00077 // Targets 00078 ID_TARGET, ID_INPUT, ID_TARGET_OUTPUT, ID_ONLY_INITIAL, 00079 ID_VISIBILITY_MASK, ID_LOD_BIAS, ID_MATERIAL_SCHEME, 00080 ID_PREVIOUS, ID_NONE, 00081 // Passes 00082 ID_PASS, 00083 ID_MATERIAL, 00084 ID_RENDER_QUAD, ID_CLEAR, ID_STENCIL, ID_RENDER_SCENE, 00085 ID_FIRST_RQ, ID_LAST_RQ, 00086 ID_IDENTIFIER, 00087 // clear 00088 ID_CLR_BUFF, ID_CLR_COLOUR, ID_CLR_DEPTH, 00089 ID_CLR_COLOUR_VAL, ID_CLR_DEPTH_VAL, ID_CLR_STENCIL_VAL, 00090 // stencil 00091 ID_ST_CHECK, ID_ST_FUNC, ID_ST_REF_VAL, ID_ST_MASK, ID_ST_FAILOP, 00092 ID_ST_DEPTH_FAILOP, ID_ST_PASSOP, ID_ST_TWOSIDED, 00093 00094 // compare functions 00095 ID_ST_ALWAYS_FAIL, ID_ST_ALWAYS_PASS, ID_ST_LESS, 00096 ID_ST_LESS_EQUAL, ID_ST_EQUAL, ID_ST_NOT_EQUAL, 00097 ID_ST_GREATER_EQUAL, ID_ST_GREATER, 00098 00099 // stencil operations 00100 ID_ST_KEEP, ID_ST_ZERO, ID_ST_REPLACE, ID_ST_INCREMENT, 00101 ID_ST_DECREMENT, ID_ST_INCREMENT_WRAP, ID_ST_DECREMENT_WRAP, 00102 ID_ST_INVERT, 00103 00104 // general 00105 ID_ON, ID_OFF, ID_TRUE, ID_FALSE 00106 }; 00107 00109 enum CompositorScriptSection 00110 { 00111 CSS_NONE, 00112 CSS_COMPOSITOR, 00113 CSS_TECHNIQUE, 00114 CSS_TARGET, 00115 CSS_PASS 00116 }; 00118 struct CompositorScriptContext 00119 { 00120 CompositorScriptSection section; 00121 String groupName; 00122 CompositorPtr compositor; 00123 CompositionTechnique* technique; 00124 CompositionTargetPass* target; 00125 CompositionPass* pass; 00126 }; 00127 00128 CompositorScriptContext mScriptContext; 00129 00130 // static library database for tokens and BNF rules 00131 static TokenRule compositorScript_RulePath[]; 00132 // simplified Backus - Naur Form (BNF) grammer for compositor scripts 00133 static String compositorScript_BNF; 00134 00135 typedef void (CompositorScriptCompiler::* CSC_Action)(void); 00136 typedef std::map<size_t, CSC_Action> TokenActionMap; 00137 typedef TokenActionMap::iterator TokenActionIterator; 00142 static TokenActionMap mTokenActionMap; 00143 00147 virtual void executeTokenAction(const size_t tokenID); 00150 virtual void setupTokenDefinitions(void); 00151 void addLexemeTokenAction(const String& lexeme, const size_t token, const CSC_Action action = 0); 00152 00153 void logParseError(const String& error); 00154 00155 // Token Actions which get called when tokens are created during parsing. 00156 void parseOpenBrace(void); 00157 void parseCloseBrace(void); 00158 void parseCompositor(void); 00159 void parseTechnique(void); 00160 void parseTexture(void); 00161 void parseTarget(void); 00162 void parseInput(void); 00163 void parseTargetOutput(void); 00164 void parseOnlyInitial(void); 00165 void parseVisibilityMask(void); 00166 void parseLodBias(void); 00167 void parseMaterialScheme(void); 00168 void parsePass(void); 00169 void parseMaterial(void); 00170 void parseFirstRenderQueue(void); 00171 void parseLastRenderQueue(void); 00172 void parseIdentifier(void); 00173 void parseClearBuffers(void); 00174 void parseClearColourValue(void); 00175 void parseClearDepthValue(void); 00176 void parseClearStencilValue(void); 00177 void parseStencilCheck(void); 00178 void parseStencilFunc(void); 00179 void parseStencilRefVal(void); 00180 void parseStencilMask(void); 00181 void parseStencilFailOp(void); 00182 void parseStencilDepthFailOp(void); 00183 void parseStencilPassOp(void); 00184 void parseStencilTwoSided(void); 00185 StencilOperation extractStencilOp(void); 00186 CompareFunction extractCompareFunc(void); 00187 }; 00188 } 00189 00190 #endif
Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Jan 21 10:01:35 2007