# Visualization Library

A lightweight C++ OpenGL middleware for 2D/3D graphics

[Home] [Tutorials] [All Classes] [Grouped Classes]

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

# D:/VL/BuildSystem/VL_DISTRO/Visualization_Library_SDK/src/vlGraphics/Effect.hpp

Go to the documentation of this file.

    00001 /**************************************************************************************/
    00002 /*                                                                                    */
    00003 /*  Visualization Library                                                             */
    00004 /*  http://www.visualizationlibrary.com                                               */
    00005 /*                                                                                    */
    00006 /*  Copyright (c) 2005-2010, Michele Bosi                                             */
    00007 /*  All rights reserved.                                                              */
    00008 /*                                                                                    */
    00009 /*  Redistribution and use in source and binary forms, with or without modification,  */
    00010 /*  are permitted provided that the following conditions are met:                     */
    00011 /*                                                                                    */
    00012 /*  - Redistributions of source code must retain the above copyright notice, this     */
    00013 /*  list of conditions and the following disclaimer.                                  */
    00014 /*                                                                                    */
    00015 /*  - Redistributions in binary form must reproduce the above copyright notice, this  */
    00016 /*  list of conditions and the following disclaimer in the documentation and/or       */
    00017 /*  other materials provided with the distribution.                                   */
    00018 /*                                                                                    */
    00019 /*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND   */
    00020 /*  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED     */
    00021 /*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE            */
    00022 /*  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR  */
    00023 /*  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES    */
    00024 /*  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;      */
    00025 /*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON    */
    00026 /*  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT           */
    00027 /*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS     */
    00028 /*  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                      */
    00029 /*                                                                                    */
    00030 /**************************************************************************************/
    00031
    00032 #ifndef Effect_INCLUDE_ONCE
    00033 #define Effect_INCLUDE_ONCE
    00034
    00035 #include <vlGraphics/Renderable.hpp>
    00036 #include <vlGraphics/LODEvaluator.hpp>
    00037 #include <vlGraphics/Shader.hpp>
    00038 #include <vlCore/Collection.hpp>
    00039 #include <vector>
    00040
    00041 namespace vl
    00042 {
    00043   class Actor;
    00044   //------------------------------------------------------------------------------
    00045   // ShaderSequence
    00046   //------------------------------------------------------------------------------
    00051   class ShaderSequence: public Collection<Shader>
    00052   {
    00053   public:
    00054     virtual const char* className() { return "vl::ShaderSequence"; }
    00061     ShaderSequence(Shader* pass1=NULL, Shader* pass2=NULL, Shader* pass3=NULL, Shader* pass4=NULL )
    00062     {
    00063       VL_DEBUG_SET_OBJECT_NAME()
    00064       if (pass1)
    00065         push_back(pass1);
    00066       if (pass2)
    00067         push_back(pass2);
    00068       if (pass3)
    00069         push_back(pass3);
    00070       if (pass4)
    00071         push_back(pass4);
    00072     }
    00073   };
    00074   //------------------------------------------------------------------------------
    00075   // Effect
    00076   //------------------------------------------------------------------------------
    00090   class VLGRAPHICS_EXPORT Effect: public Object
    00091   {
    00092     // mic fixme: define these?
    00093     Effect(const Effect&): Object() {}
    00094     Effect& operator=(const Effect&) { return *this; }
    00095
    00096   public:
    00097     virtual const char* className() { return "vl::Effect"; }
    00098
    00100     Effect()
    00101     {
    00102       VL_DEBUG_SET_OBJECT_NAME()
    00103       mEnableMask = 0xFFFFFFFF;
    00104       mRenderRank = 0;
    00105       mActiveLod  = 0;
    00106       mLODShaders[0] = new ShaderSequence(new Shader);
    00107     }
    00108
    00115     void setRenderRank(int rank) { mRenderRank = rank; }
    00116
    00118     int renderRank() const { return mRenderRank; }
    00119
    00122     const ref<ShaderSequence>& lod(int lod_level) const { return mLODShaders[lod_level]; }
    00123
    00126     ref<ShaderSequence>& lod(int lod_level) { return mLODShaders[lod_level]; }
    00127
    00129     Shader* shader(int lodi=0, int pass=0) { return lod(lodi)->at(pass); }
    00130
    00132     const Shader* shader(int lodi=0, int pass=0) const { return lod(lodi)->at(pass); }
    00133
    00135     void setLOD(int lodi, Shader* shader1, Shader* shader2=NULL, Shader* shader3=NULL, Shader* shader4=NULL)
    00136     {
    00137       VL_CHECK(lodi<VL_MAX_EFFECT_LOD)
    00138       lod(lodi) = new ShaderSequence(shader1,shader2,shader3,shader4);
    00139     }
    00140
    00142     void setLODEvaluator(LODEvaluator* lod_evaluator) { mLODEvaluator = lod_evaluator; }
    00143
    00145     LODEvaluator* lodEvaluator() { return mLODEvaluator.get(); }
    00146
    00148     const LODEvaluator* lodEvaluator() const { return mLODEvaluator.get(); }
    00149
    00151     void setEnableMask(unsigned int mask) { mEnableMask = mask; }
    00152
    00154     unsigned int enableMask() const { return mEnableMask; }
    00155
    00157     int evaluateLOD(Actor* actor, Camera* camera);
    00158
    00160     void setActiveLod(int lod)
    00161     {
    00162       VL_CHECK( lod < VL_MAX_EFFECT_LOD )
    00163       VL_CHECK( lod >= 0 )
    00164       mActiveLod = lod;
    00165     }
    00166
    00168     int activeLod() const { return mActiveLod; }
    00169
    00170   protected:
    00171     ref<ShaderSequence> mLODShaders[VL_MAX_EFFECT_LOD];
    00172     ref<LODEvaluator> mLODEvaluator;
    00173     int mActiveLod;
    00174     int mRenderRank;
    00175     unsigned int mEnableMask;
    00176   };
    00177   //------------------------------------------------------------------------------
    00178 }
    00179
    00180 #endif

Visualization Library v2011.05.1142 Reference Documentation
Copyright 2005-2011 Michele Bosi. All rights reserved.
Updated on Thu May 26 2011 22:51:23.
Permission is granted to use this page to write and publish articles regarding Visualization Library.