- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

# 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_PF_A8R8G8B8, ID_PF_R8G8B8A8, ID_PF_R8G8B8,
    00078             ID_PF_FLOAT16_R, ID_PF_FLOAT16_RGB, ID_PF_FLOAT16_RGBA,
    00079             ID_PF_FLOAT32_R, ID_PF_FLOAT32_RGB, ID_PF_FLOAT32_RGBA,
    00080             ID_PF_FLOAT16_GR, ID_PF_FLOAT32_GR,
    00081             // Targets
    00082             ID_PREVIOUS, ID_NONE,
    00083             // Passes
    00084             ID_RENDER_QUAD, ID_CLEAR, ID_STENCIL, ID_RENDER_SCENE,
    00085             // Clear section
    00086             ID_CLR_COLOUR, ID_CLR_DEPTH,
    00087             // Stencil section
    00088
    00089             // compare functions
    00090             ID_ST_ALWAYS_FAIL, ID_ST_ALWAYS_PASS, ID_ST_LESS,
    00091             ID_ST_LESS_EQUAL, ID_ST_EQUAL, ID_ST_NOT_EQUAL,
    00092             ID_ST_GREATER_EQUAL, ID_ST_GREATER,
    00093
    00094             // stencil operations
    00095             ID_ST_KEEP, ID_ST_ZERO, ID_ST_REPLACE, ID_ST_INCREMENT,
    00096             ID_ST_DECREMENT, ID_ST_INCREMENT_WRAP, ID_ST_DECREMENT_WRAP,
    00097             ID_ST_INVERT,
    00098
    00099             // general
    00100             ID_ON, ID_OFF, ID_TRUE, ID_FALSE,
    00101             // where auto generated tokens start so donot remove
    00102             ID_AUTOTOKENSTART
    00103         };
    00104
    00106         enum CompositorScriptSection
    00107         {
    00108             CSS_NONE,
    00109             CSS_COMPOSITOR,
    00110             CSS_TECHNIQUE,
    00111             CSS_TARGET,
    00112             CSS_PASS
    00113         };
    00115         struct CompositorScriptContext
    00116         {
    00117             CompositorScriptSection section;
    00118             String groupName;
    00119             CompositorPtr compositor;
    00120             CompositionTechnique* technique;
    00121             CompositionTargetPass* target;
    00122             CompositionPass* pass;
    00123         };
    00124
    00125         CompositorScriptContext mScriptContext;
    00126
    00127         typedef void (CompositorScriptCompiler::* CSC_Action)(void);
    00128         typedef std::map<size_t, CSC_Action> TokenActionMap;
    00129         typedef TokenActionMap::iterator TokenActionIterator;
    00134         static TokenActionMap mTokenActionMap;
    00135
    00139         virtual void executeTokenAction(const size_t tokenID);
    00142         virtual size_t getAutoTokenIDStart() const {return ID_AUTOTOKENSTART;}
    00145         virtual void setupTokenDefinitions(void);
    00146         void addLexemeTokenAction(const String& lexeme, const size_t token, const CSC_Action action = 0);
    00147         void addLexemeAction(const String& lexeme, const CSC_Action action) { addLexemeTokenAction(lexeme, 0, action); }
    00148
    00149         void logParseError(const String& error);
    00150
    00151         // Token Actions which get called when tokens are created during parsing.
    00152         void parseOpenBrace(void);
    00153         void parseCloseBrace(void);
    00154         void parseCompositor(void);
    00155         void parseTechnique(void);
    00156         void parseTexture(void);
    00157         void parseTarget(void);
    00158         void parseInput(void);
    00159         void parseTargetOutput(void);
    00160         void parseOnlyInitial(void);
    00161         void parseVisibilityMask(void);
    00162         void parseLodBias(void);
    00163         void parseMaterialScheme(void);
    00164         void parsePass(void);
    00165         void parseMaterial(void);
    00166         void parseFirstRenderQueue(void);
    00167         void parseLastRenderQueue(void);
    00168         void parseIdentifier(void);
    00169         void parseClearBuffers(void);
    00170         void parseClearColourValue(void);
    00171         void parseClearDepthValue(void);
    00172         void parseClearStencilValue(void);
    00173         void parseStencilCheck(void);
    00174         void parseStencilFunc(void);
    00175         void parseStencilRefVal(void);
    00176         void parseStencilMask(void);
    00177         void parseStencilFailOp(void);
    00178         void parseStencilDepthFailOp(void);
    00179         void parseStencilPassOp(void);
    00180         void parseStencilTwoSided(void);
    00181         StencilOperation extractStencilOp(void);
    00182         CompareFunction extractCompareFunc(void);
    00183     };
    00184 }
    00185
    00186 #endif

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Mon Jun 16 12:48:50 2008