PixelLightAPI  .
EffectManager.h
Go to the documentation of this file.
00001 /*********************************************************\
00002  *  File: EffectManager.h                                *
00003  *
00004  *  Copyright (C) 2002-2012 The PixelLight Team (http://www.pixellight.org/)
00005  *
00006  *  This file is part of PixelLight.
00007  *
00008  *  PixelLight is free software: you can redistribute it and/or modify
00009  *  it under the terms of the GNU Lesser General Public License as published by
00010  *  the Free Software Foundation, either version 3 of the License, or
00011  *  (at your option) any later version.
00012  *
00013  *  PixelLight is distributed in the hope that it will be useful,
00014  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00016  *  GNU Lesser General Public License for more details.
00017  *
00018  *  You should have received a copy of the GNU Lesser General Public License
00019  *  along with PixelLight. If not, see <http://www.gnu.org/licenses/>.
00020 \*********************************************************/
00021 
00022 
00023 #ifndef __PLRENDERER_EFFECT_MANAGER_H__
00024 #define __PLRENDERER_EFFECT_MANAGER_H__
00025 #pragma once
00026 
00027 
00028 //[-------------------------------------------------------]
00029 //[ Includes                                              ]
00030 //[-------------------------------------------------------]
00031 #include <PLCore/Container/ResourceManager.h>
00032 #include "PLRenderer/Effect/Effect.h"
00033 #include "PLRenderer/Effect/EffectHandler.h"
00034 
00035 
00036 //[-------------------------------------------------------]
00037 //[ Namespace                                             ]
00038 //[-------------------------------------------------------]
00039 namespace PLRenderer {
00040 
00041 
00042 //[-------------------------------------------------------]
00043 //[ Forward declarations                                  ]
00044 //[-------------------------------------------------------]
00045 class Effect;
00046 class EffectHandler;
00047 class RendererContext;
00048 
00049 
00050 //[-------------------------------------------------------]
00051 //[ Classes                                               ]
00052 //[-------------------------------------------------------]
00053 /**
00054 *  @brief
00055 *    This is a manager for the effect resource
00056 *
00057 *  @note
00058 *    - Unloads unused resources automatically by default
00059 *    - The public static effect strings within this class are just filenames without any
00060 *      fixed functionality
00061 */
00062 class EffectManager : public PLCore::ResourceManager<Effect> {
00063 
00064 
00065     //[-------------------------------------------------------]
00066     //[ Friends                                               ]
00067     //[-------------------------------------------------------]
00068     friend class RendererContext;
00069 
00070 
00071     //[-------------------------------------------------------]
00072     //[ Public static data                                    ]
00073     //[-------------------------------------------------------]
00074     public:
00075         static PLRENDERER_API const PLCore::String Default; /**< Default effect, ('Default') dynamically created within the 'EffectManager'-constructor */
00076 
00077 
00078     //[-------------------------------------------------------]
00079     //[ Public functions                                      ]
00080     //[-------------------------------------------------------]
00081     public:
00082         /**
00083         *  @brief
00084         *    Returns the owner renderer context of this manager
00085         *
00086         *  @return
00087         *    Reference to the owner renderer context of this manager
00088         */
00089         inline RendererContext &GetRendererContext() const;
00090 
00091         /**
00092         *  @brief
00093         *    Reloads all effects
00094         *
00095         *  @return
00096         *    'true' if all went fine, else 'false'
00097         */
00098         PLRENDERER_API bool ReloadEffects();
00099 
00100         /**
00101         *  @brief
00102         *    Uses a given effect
00103         *
00104         *  @param[in] sName
00105         *    Name of the effect to use
00106         *
00107         *  @remarks
00108         *    This function is calling the Bind() and SetupPass(0) function of the given effect.
00109         *    The name is in fact the filename of the effect. It's recommended to use only the
00110         *    predefined names within this class within this function because this resources are
00111         *    loaded and marked as protected by default. If you use any other effect, ensure that this
00112         *    effect is protected in order to avoid frequently loading/destruction of the resource in
00113         *    the worst case. It's recommended to use this function ONLY if you want to set 'some known'
00114         *    render states without doing this by hand.
00115         *
00116         *  @return
00117         *    'true' if all went fine, else 'false'
00118         */
00119         PLRENDERER_API bool Use(const PLCore::String &sName = Default);
00120 
00121 
00122     //[-------------------------------------------------------]
00123     //[ Private functions                                     ]
00124     //[-------------------------------------------------------]
00125     private:
00126         /**
00127         *  @brief
00128         *    Constructor
00129         *
00130         *  @param[in] cRendererContext
00131         *    Owner renderer context
00132         */
00133         EffectManager(RendererContext &cRendererContext);
00134 
00135         /**
00136         *  @brief
00137         *    Destructor
00138         */
00139         virtual ~EffectManager();
00140 
00141 
00142     //[-------------------------------------------------------]
00143     //[ Private data                                          ]
00144     //[-------------------------------------------------------]
00145     private:
00146         RendererContext *m_pRendererContext;    /**< Owner renderer context of this manager, always valid! */
00147         EffectHandler   *m_pDefault;            /**< Default effect handler (always valid pointer!) */
00148 
00149 
00150     //[-------------------------------------------------------]
00151     //[ Private virtual PLCore::ResourceManager functions     ]
00152     //[-------------------------------------------------------]
00153     private:
00154         virtual Effect *CreateResource(const PLCore::String &sName) override;
00155 
00156 
00157 };
00158 
00159 
00160 //[-------------------------------------------------------]
00161 //[ Namespace                                             ]
00162 //[-------------------------------------------------------]
00163 } // PLRenderer
00164 
00165 
00166 //[-------------------------------------------------------]
00167 //[ Implementation                                        ]
00168 //[-------------------------------------------------------]
00169 #include "PLRenderer/Effect/EffectManager.inl"
00170 
00171 
00172 #endif // __PLRENDERER_EFFECT_MANAGER_H__


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:08:52
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported