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) { static const String grammerName("Compositor Script"); return grammerName; } 00052 00053 protected: 00054 // Token ID enumeration 00055 enum TokenID { 00056 // Terminal Tokens section 00057 ID_UNKOWN = 0, ID_OPENBRACE, ID_CLOSEBRACE, 00058 // Top level 00059 ID_COMPOSITOR, 00060 // Techniques 00061 ID_TECHNIQUE, ID_TEXTURE, ID_TARGET_WIDTH, ID_TARGET_HEIGHT, 00062 ID_PF_A8R8G8B8, ID_PF_R8G8B8A8, ID_PF_R8G8B8, 00063 ID_PF_FLOAT16_R, ID_PF_FLOAT16_RGB, ID_PF_FLOAT16_RGBA, 00064 ID_PF_FLOAT32_R, ID_PF_FLOAT32_RGB, ID_PF_FLOAT32_RGBA, 00065 // Targets 00066 ID_TARGET, ID_INPUT, ID_TARGET_OUTPUT, ID_ONLY_INITIAL, 00067 ID_VISIBILITY_MASK, ID_LOD_BIAS, ID_MATERIAL_SCHEME, 00068 ID_PREVIOUS, ID_NONE, 00069 // Passes 00070 ID_PASS, 00071 ID_MATERIAL, 00072 ID_RENDER_QUAD, ID_CLEAR, ID_STENCIL, ID_RENDER_SCENE, 00073 ID_FIRST_RQ, ID_LAST_RQ, 00074 // clear 00075 ID_CLR_BUFF, ID_CLR_COLOUR, ID_CLR_DEPTH, 00076 ID_CLR_COLOUR_VAL, ID_CLR_DEPTH_VAL, ID_CLR_STENCIL_VAL, 00077 // stencil 00078 ID_ST_CHECK, ID_ST_FUNC, ID_ST_REF_VAL, ID_ST_MASK, ID_ST_FAILOP, 00079 ID_ST_DEPTH_FAILOP, ID_ST_PASSOP, ID_ST_TWOSIDED, 00080 00081 // compare functions 00082 ID_ST_ALWAYS_FAIL, ID_ST_ALWAYS_PASS, ID_ST_LESS, 00083 ID_ST_LESS_EQUAL, ID_ST_EQUAL, ID_ST_NOT_EQUAL, 00084 ID_ST_GREATER_EQUAL, ID_ST_GREATER, 00085 00086 // stencil operations 00087 ID_ST_KEEP, ID_ST_ZERO, ID_ST_REPLACE, ID_ST_INCREMENT, 00088 ID_ST_DECREMENT, ID_ST_INCREMENT_WRAP, ID_ST_DECREMENT_WRAP, 00089 ID_ST_INVERT, 00090 00091 // general 00092 ID_ON, ID_OFF, ID_TRUE, ID_FALSE 00093 }; 00094 00096 enum CompositorScriptSection 00097 { 00098 CSS_NONE, 00099 CSS_COMPOSITOR, 00100 CSS_TECHNIQUE, 00101 CSS_TARGET, 00102 CSS_PASS 00103 }; 00105 struct CompositorScriptContext 00106 { 00107 CompositorScriptSection section; 00108 CompositorPtr compositor; 00109 CompositionTechnique* technique; 00110 CompositionTargetPass* target; 00111 CompositionPass* pass; 00112 }; 00113 00114 CompositorScriptContext mScriptContext; 00115 00116 // static library database for tokens and BNF rules 00117 static TokenRule compositorScript_RulePath[]; 00118 // simplified Backus - Naur Form (BNF) grammer for compositor scripts 00119 static String compositorScript_BNF; 00120 00121 typedef void (CompositorScriptCompiler::* CSC_Action)(void); 00122 typedef std::map<size_t, CSC_Action> TokenActionMap; 00123 typedef TokenActionMap::iterator TokenActionIterator; 00128 static TokenActionMap mTokenActionMap; 00129 00133 virtual void executeTokenAction(const size_t tokenID); 00136 virtual void setupTokenDefinitions(void); 00137 void addLexemeTokenAction(const String& lexeme, const size_t token, const CSC_Action action = 0); 00138 00139 void logParseError(const String& error); 00140 00141 // Token Actions which get called when tokens are created during parsing. 00142 void parseOpenBrace(void); 00143 void parseCloseBrace(void); 00144 void parseCompositor(void); 00145 void parseTechnique(void); 00146 void parseTexture(void); 00147 void parseTarget(void); 00148 void parseInput(void); 00149 void parseTargetOutput(void); 00150 void parseOnlyInitial(void); 00151 void parseVisibilityMask(void); 00152 void parseLodBias(void); 00153 void parseMaterialScheme(void); 00154 void parsePass(void); 00155 void parseMaterial(void); 00156 void parseFirstRenderQueue(void); 00157 void parseLastRenderQueue(void); 00158 void parseClearBuffers(void); 00159 void parseClearColourValue(void); 00160 void parseClearDepthValue(void); 00161 void parseClearStencilValue(void); 00162 void parseStencilCheck(void); 00163 void parseStencilFunc(void); 00164 void parseStencilRefVal(void); 00165 void parseStencilMask(void); 00166 void parseStencilFailOp(void); 00167 void parseStencilDepthFailOp(void); 00168 void parseStencilPassOp(void); 00169 void parseStencilTwoSided(void); 00170 StencilOperation extractStencilOp(void); 00171 CompareFunction extractCompareFunc(void); 00172 }; 00173 } 00174 00175 #endif
Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:37:39 2006