OgreCompositorScriptCompiler.h

Go to the documentation of this file.
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-2006 Torus Knot Software Ltd
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 Lesser 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 Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser 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/lesser.txt.
00023 
00024 You may alternatively use this source under the terms of a specific version of
00025 the OGRE Unrestricted License provided you have obtained such a license from
00026 Torus Knot Software Ltd.
00027 -----------------------------------------------------------------------------
00028 */
00029 
00030 #ifndef __CompositorScriptScompiler_H__
00031 #define __CompositorScriptScompiler_H__
00032 
00033 #include "OgrePrerequisites.h"
00034 #include "OgreCompiler2Pass.h"
00035 #include "OgreCompositor.h"
00036 #include "OgreRenderSystem.h"
00037 
00038 
00039 namespace Ogre {
00040 
00042     class _OgreExport CompositorScriptCompiler : public Compiler2Pass
00043     {
00044 
00045     public:
00046         CompositorScriptCompiler(void);
00047         ~CompositorScriptCompiler(void);
00048 
00051         virtual const String& getClientBNFGrammer(void) const;
00052 
00055         virtual const String& getClientGrammerName(void) const;
00056 
00064         void parseScript(DataStreamPtr& stream, const String& groupName)
00065         {
00066             mScriptContext.groupName = groupName;
00067             Compiler2Pass::compile(stream->getAsString(),  stream->getName());
00068         }
00069 
00070     protected:
00071         // Token ID enumeration
00072         enum TokenID {
00073             // Terminal Tokens section
00074             ID_UNKOWN = 0,
00075             // Techniques
00076             ID_TARGET_WIDTH, ID_TARGET_HEIGHT,
00077             ID_TARGET_WIDTH_SCALED, ID_TARGET_HEIGHT_SCALED,
00078             ID_PF_A8R8G8B8, ID_PF_R8G8B8A8, ID_PF_R8G8B8, 
00079             ID_PF_FLOAT16_R, ID_PF_FLOAT16_RGB, ID_PF_FLOAT16_RGBA,
00080             ID_PF_FLOAT32_R, ID_PF_FLOAT32_RGB, ID_PF_FLOAT32_RGBA,
00081             ID_PF_FLOAT16_GR, ID_PF_FLOAT32_GR,
00082             // Targets
00083             ID_PREVIOUS, ID_NONE,
00084             // Passes
00085             ID_RENDER_QUAD, ID_CLEAR, ID_STENCIL, ID_RENDER_SCENE,
00086             // Clear section
00087             ID_CLR_COLOUR, ID_CLR_DEPTH,
00088             // Stencil section
00089 
00090             // compare functions
00091             ID_ST_ALWAYS_FAIL, ID_ST_ALWAYS_PASS, ID_ST_LESS,
00092             ID_ST_LESS_EQUAL, ID_ST_EQUAL, ID_ST_NOT_EQUAL,
00093             ID_ST_GREATER_EQUAL, ID_ST_GREATER,
00094 
00095             // stencil operations
00096             ID_ST_KEEP, ID_ST_ZERO, ID_ST_REPLACE, ID_ST_INCREMENT,
00097             ID_ST_DECREMENT, ID_ST_INCREMENT_WRAP, ID_ST_DECREMENT_WRAP,
00098             ID_ST_INVERT,
00099 
00100             // general
00101             ID_ON, ID_OFF, ID_TRUE, ID_FALSE,
00102             // where auto generated tokens start so do not remove
00103             ID_AUTOTOKENSTART
00104         };
00105 
00107         enum CompositorScriptSection
00108         {
00109             CSS_NONE,
00110             CSS_COMPOSITOR,
00111             CSS_TECHNIQUE,
00112             CSS_TARGET,
00113             CSS_PASS
00114         };
00116         struct CompositorScriptContext
00117         {
00118             CompositorScriptSection section;
00119             String groupName;
00120             CompositorPtr compositor;
00121             CompositionTechnique* technique;
00122             CompositionTargetPass* target;
00123             CompositionPass* pass;
00124         };
00125 
00126         CompositorScriptContext mScriptContext;
00127 
00128         typedef void (CompositorScriptCompiler::* CSC_Action)(void);
00129         typedef std::map<size_t, CSC_Action> TokenActionMap;
00130         typedef TokenActionMap::iterator TokenActionIterator;
00135         static TokenActionMap mTokenActionMap;
00136 
00140         virtual void executeTokenAction(const size_t tokenID);
00143         virtual size_t getAutoTokenIDStart() const {return ID_AUTOTOKENSTART;}
00146         virtual void setupTokenDefinitions(void);
00147         void addLexemeTokenAction(const String& lexeme, const size_t token, const CSC_Action action = 0);
00148         void addLexemeAction(const String& lexeme, const CSC_Action action) { addLexemeTokenAction(lexeme, 0, action); }
00149 
00150         void logParseError(const String& error);
00151 
00152         // Token Actions which get called when tokens are created during parsing.
00153         void parseOpenBrace(void);
00154         void parseCloseBrace(void);
00155         void parseCompositor(void);
00156         void parseTechnique(void);
00157         void parseTexture(void);
00158         void parseTarget(void);
00159         void parseInput(void);
00160         void parseTargetOutput(void);
00161         void parseOnlyInitial(void);
00162         void parseVisibilityMask(void);
00163         void parseLodBias(void);
00164         void parseMaterialScheme(void);
00165         void parseShadowsEnabled(void);
00166         void parsePass(void);
00167         void parseMaterial(void);
00168         void parseFirstRenderQueue(void);
00169         void parseLastRenderQueue(void);
00170         void parseIdentifier(void);
00171         void parseClearBuffers(void);
00172         void parseClearColourValue(void);
00173         void parseClearDepthValue(void);
00174         void parseClearStencilValue(void);
00175         void parseStencilCheck(void);
00176         void parseStencilFunc(void);
00177         void parseStencilRefVal(void);
00178         void parseStencilMask(void);
00179         void parseStencilFailOp(void);
00180         void parseStencilDepthFailOp(void);
00181         void parseStencilPassOp(void);
00182         void parseStencilTwoSided(void);
00183         StencilOperation extractStencilOp(void);
00184         CompareFunction extractCompareFunc(void);
00185     };
00186 }
00187 
00188 #endif

Copyright © 2008 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Sep 27 22:02:22 2009