00001 /*************************************************************************** 00002 * Copyright (C) 2005-2008 by the FIFE team * 00003 * http://www.fifengine.de * 00004 * This file is part of FIFE. * 00005 * * 00006 * FIFE is free software; you can redistribute it and/or * 00007 * modify it under the terms of the GNU Lesser General Public * 00008 * License as published by the Free Software Foundation; either * 00009 * version 2.1 of the License, or (at your option) any later version. * 00010 * * 00011 * This library is distributed in the hope that it will be useful, * 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00014 * Lesser General Public License for more details. * 00015 * * 00016 * You should have received a copy of the GNU Lesser General Public * 00017 * License along with this library; if not, write to the * 00018 * Free Software Foundation, Inc., * 00019 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 00020 ***************************************************************************/ 00021 00022 #ifndef FIFE_RENDERERBASE_H 00023 #define FIFE_RENDERERBASE_H 00024 00025 // Standard C++ library includes 00026 #include <list> 00027 #include <vector> 00028 00029 // 3rd party library includes 00030 00031 // FIFE includes 00032 // These includes are split up in two parts, separated by one empty line 00033 // First block: files included from the FIFE root src directory 00034 // Second block: files included from the same folder 00035 00036 namespace FIFE { 00037 class Camera; 00038 class Layer; 00039 class Map; 00040 class Instance; 00041 class RenderBackend; 00042 00043 class RendererBase; 00048 class IRendererListener { 00049 public: 00050 virtual ~IRendererListener() {} 00051 00054 virtual void onRendererPipelinePositionChanged(RendererBase* renderer) = 0; 00055 00058 virtual void onRendererEnabledChanged(RendererBase* renderer) = 0; 00059 }; 00060 00064 class IRendererContainer { 00065 public: 00066 virtual ~IRendererContainer() {} 00067 00070 virtual RendererBase* getRenderer(const std::string& renderername) = 0; 00071 }; 00072 00076 class RendererBase { 00077 public: 00082 RendererBase(RenderBackend* renderbackend, int position); 00083 00086 RendererBase(const RendererBase& old); 00087 00090 virtual RendererBase* clone() = 0; 00091 00094 virtual ~RendererBase() {}; 00095 00107 virtual void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances) = 0; 00108 00111 virtual std::string getName() = 0; 00112 00115 int getPipelinePosition() const { return m_pipeline_position; } 00116 00122 void setPipelinePosition(int position); 00123 00126 virtual void setEnabled(bool enabled); 00127 00130 virtual void reset() {} 00131 00134 bool isEnabled() const { return m_enabled; } 00135 00138 void setRendererListener(IRendererListener* listener) { m_listener = listener; } 00139 00142 void addActiveLayer(Layer* layer); 00143 00146 void removeActiveLayer(Layer* layer); 00147 00150 void clearActiveLayers(); 00151 00154 void activateAllLayers(Map* elevation); 00155 00158 bool isActivedLayer(Layer* layer); 00159 00160 00161 protected: 00162 RendererBase(); 00163 00164 std::list<Layer*> m_active_layers; 00165 RenderBackend* m_renderbackend; 00166 00167 private: 00168 bool m_enabled; 00169 int m_pipeline_position; 00170 IRendererListener* m_listener; 00171 }; 00172 } 00173 00174 #endif