Mercurial > fife-parpg
changeset 32:75b6394ced14
* remove geometric renderer, its not replaced by the more functional generic renderern
* add grouing to generic renderer, probably this should be exported to the client in any way
author | spq@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Fri, 11 Jul 2008 15:37:16 +0000 |
parents | 9a9f4447af7c |
children | 112fc4af772d |
files | engine/core/controller/engine.cpp engine/core/view/renderers/genericrenderer.cpp engine/core/view/renderers/genericrenderer.h engine/core/view/renderers/genericrenderer.i engine/core/view/renderers/geometricrenderer.cpp engine/core/view/renderers/geometricrenderer.h engine/core/view/renderers/geometricrenderer.i |
diffstat | 7 files changed, 41 insertions(+), 234 deletions(-) [+] |
line wrap: on
line diff
--- a/engine/core/controller/engine.cpp Fri Jul 11 14:35:31 2008 +0000 +++ b/engine/core/controller/engine.cpp Fri Jul 11 15:37:16 2008 +0000 @@ -74,7 +74,6 @@ #include "view/renderers/floatingtextrenderer.h" #include "view/renderers/cellselectionrenderer.h" #include "view/renderers/blockinginforenderer.h" -#include "view/renderers/geometricrenderer.h" #include "view/renderers/genericrenderer.h" #include "engine.h" @@ -245,8 +244,7 @@ m_view->addRenderer(new FloatingTextRenderer(m_renderbackend, 50, dynamic_cast<AbstractFont*>(m_defaultfont))); m_view->addRenderer(new QuadTreeRenderer(m_renderbackend, 60)); m_view->addRenderer(new CoordinateRenderer(m_renderbackend, 70, dynamic_cast<AbstractFont*>(m_defaultfont))); - m_view->addRenderer(new GeometricRenderer(m_renderbackend, 80)); - m_view->addRenderer(new GenericRenderer(m_renderbackend, 100, m_imagepool, m_animpool)); + m_view->addRenderer(new GenericRenderer(m_renderbackend, 80, m_imagepool, m_animpool)); m_cursor = new Cursor(m_imagepool, m_animpool, m_renderbackend); FL_LOG(_log, "Engine intialized"); }
--- a/engine/core/view/renderers/genericrenderer.cpp Fri Jul 11 14:35:31 2008 +0000 +++ b/engine/core/view/renderers/genericrenderer.cpp Fri Jul 11 15:37:16 2008 +0000 @@ -287,7 +287,7 @@ RendererBase(renderbackend, position), m_imagepool(imagepool), m_animationpool(animpool), - m_infos() { + m_groups() { setEnabled(false); } @@ -295,7 +295,7 @@ RendererBase(old), m_imagepool(old.m_imagepool), m_animationpool(old.m_animationpool), - m_infos() { + m_groups() { setEnabled(false); } @@ -305,43 +305,46 @@ GenericRenderer::~GenericRenderer() { } - void GenericRenderer::addLine(GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b) { + void GenericRenderer::addLine(int group, GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b) { GenericRendererElementInfo* info = new GenericRendererLineInfo(n1, n2, r, g, b); - m_infos.push_back(info); + m_groups[group].push_back(info); } - void GenericRenderer::addPoint(GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b) { + void GenericRenderer::addPoint(int group, GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b) { GenericRendererElementInfo* info = new GenericRendererPointInfo(n, r, g, b); - m_infos.push_back(info); + m_groups[group].push_back(info); } - void GenericRenderer::addQuad(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b) { + void GenericRenderer::addQuad(int group, GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b) { GenericRendererElementInfo* info = new GenericRendererQuadInfo(n1, n2, n3, n4, r, g, b); - m_infos.push_back(info); + m_groups[group].push_back(info); } - void GenericRenderer::addText(GenericRendererNode n, AbstractFont* font, std::string text) { + void GenericRenderer::addText(int group, GenericRendererNode n, AbstractFont* font, std::string text) { GenericRendererElementInfo* info = new GenericRendererTextInfo(n, font, text); - m_infos.push_back(info); + m_groups[group].push_back(info); } - void GenericRenderer::addImage(GenericRendererNode n, int image) { + void GenericRenderer::addImage(int group, GenericRendererNode n, int image) { GenericRendererElementInfo* info = new GenericRendererImageInfo(n, image); - m_infos.push_back(info); + m_groups[group].push_back(info); } - void GenericRenderer::addAnimation(GenericRendererNode n, int animation) { + void GenericRenderer::addAnimation(int group, GenericRendererNode n, int animation) { GenericRendererElementInfo* info = new GenericRendererAnimationInfo(n, animation); - m_infos.push_back(info); + m_groups[group].push_back(info); } - void GenericRenderer::removeAll() { - std::vector<GenericRendererElementInfo*>::const_iterator info_it = m_infos.begin(); - for (;info_it != m_infos.end(); ++info_it) { + void GenericRenderer::removeAll(int group) { + std::vector<GenericRendererElementInfo*>::const_iterator info_it = m_groups[group].begin(); + for (;info_it != m_groups[group].end(); ++info_it) { delete *info_it; } - m_infos.clear(); + m_groups[group].clear(); + m_groups.erase(group); } void GenericRenderer::render(Camera* cam, Layer* layer, std::vector<Instance*>& instances) { - std::vector<GenericRendererElementInfo*>::const_iterator info_it = m_infos.begin(); - for (;info_it != m_infos.end(); ++info_it) { - GenericRendererElementInfo* info = *info_it; - info->render(cam, layer, instances, m_renderbackend, m_imagepool, m_animationpool); + std::map<int, std::vector<GenericRendererElementInfo*> >::iterator group_it = m_groups.begin(); + for(; group_it != m_groups.end(); ++group_it) { + std::vector<GenericRendererElementInfo*>::const_iterator info_it = group_it->second.begin(); + for (;info_it != group_it->second.end(); ++info_it) { + (*info_it)->render(cam, layer, instances, m_renderbackend, m_imagepool, m_animationpool); + } } } }
--- a/engine/core/view/renderers/genericrenderer.h Fri Jul 11 14:35:31 2008 +0000 +++ b/engine/core/view/renderers/genericrenderer.h Fri Jul 11 15:37:16 2008 +0000 @@ -170,18 +170,18 @@ */ static GenericRenderer* getInstance(IRendererContainer* cnt); - void addLine(GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b); - void addPoint(GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b); - void addQuad(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b); - void addText(GenericRendererNode n, AbstractFont* font, std::string text); - void addImage(GenericRendererNode n, int image); - void addAnimation(GenericRendererNode n, int animation); - void removeAll(); + void addLine(int group, GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b); + void addPoint(int group, GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b); + void addQuad(int group, GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b); + void addText(int group, GenericRendererNode n, AbstractFont* font, std::string text); + void addImage(int group, GenericRendererNode n, int image); + void addAnimation(int group, GenericRendererNode n, int animation); + void removeAll(int group); private: ImagePool* m_imagepool; AnimationPool* m_animationpool; - std::vector<GenericRendererElementInfo*> m_infos; + std::map<int, std::vector<GenericRendererElementInfo*> > m_groups; }; }
--- a/engine/core/view/renderers/genericrenderer.i Fri Jul 11 14:35:31 2008 +0000 +++ b/engine/core/view/renderers/genericrenderer.i Fri Jul 11 15:37:16 2008 +0000 @@ -120,12 +120,12 @@ ~GeometricRenderer(); std::string getName(); static GenericRenderer* getInstance(IRendererContainer* cnt); - void addLine(GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b); - void addPoint(GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b); - void addQuad(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b); - void addText(GenericRendererNode n, AbstractFont* font, std::string text); - void addImage(GenericRendererNode n, int image); - void addAnimation(GenericRendererNode n, int animation); - void removeAll(); + void addLine(int group, GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b); + void addPoint(int group, GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b); + void addQuad(int group, GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b); + void addText(int group, GenericRendererNode n, AbstractFont* font, std::string text); + void addImage(int group, GenericRendererNode n, int image); + void addAnimation(int group, GenericRendererNode n, int animation); + void removeAll(int group); }; }
--- a/engine/core/view/renderers/geometricrenderer.cpp Fri Jul 11 14:35:31 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2008 by the FIFE team * - * http://www.fifengine.de * - * This file is part of FIFE. * - * * - * FIFE is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ - -// Standard C++ library includes - -// 3rd party library includes - -// FIFE includes -// These includes are split up in two parts, separated by one empty line -// First block: files included from the FIFE root src directory -// Second block: files included from the same folder -#include "video/renderbackend.h" -#include "util/math/fife_math.h" -#include "util/log/logger.h" -#include "model/metamodel/grids/cellgrid.h" -#include "model/structures/instance.h" -#include "model/structures/layer.h" -#include "model/structures/location.h" - -#include "view/camera.h" -#include "geometricrenderer.h" - - -namespace FIFE { - static Logger _log(LM_VIEWVIEW); - GeometricRenderer::LineInfo::LineInfo(Point p1, Point p2, int r, int g, int b): - p1(p1), - p2(p2), - r(r), - g(g), - b(b) { - } - - GeometricRenderer* GeometricRenderer::getInstance(IRendererContainer* cnt) { - return dynamic_cast<GeometricRenderer*>(cnt->getRenderer("GeometricRenderer")); - } - - GeometricRenderer::GeometricRenderer(RenderBackend* renderbackend, int position): - RendererBase(renderbackend, position), - m_lines() { - setEnabled(false); - } - - GeometricRenderer::GeometricRenderer(const GeometricRenderer& old): - RendererBase(old) { - setEnabled(false); - } - - RendererBase* GeometricRenderer::clone() { - return new GeometricRenderer(*this); - } - - GeometricRenderer::~GeometricRenderer() { - } - - void GeometricRenderer::addLine(Point p1, Point p2, int r, int g, int b) { - LineInfo info(p1, p2, r, g, b); - m_lines.push_back(info); - } - - void GeometricRenderer::removeAllLines() { - m_lines.clear(); - } - - void GeometricRenderer::render(Camera* cam, Layer* layer, std::vector<Instance*>& instances) { - std::vector<LineInfo>::const_iterator lineinfo_it = m_lines.begin(); - for (;lineinfo_it != m_lines.end(); ++lineinfo_it) { - LineInfo info = *lineinfo_it; - m_renderbackend->drawLine(info.p1, info.p2, info.r, info.g, info.b); - } - } -}
--- a/engine/core/view/renderers/geometricrenderer.h Fri Jul 11 14:35:31 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005-2008 by the FIFE Team * - * http://www.fifengine.de * - * This file is part of FIFE. * - * * - * FIFE is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ - -#ifndef FIFE_GEOMETRICRENDERER_H -#define FIFE_GEOMETRICRENDERER_H - -// Standard C++ library includes - -// 3rd party library includes - -// FIFE includes -// These includes are split up in two parts, separated by one empty line -// First block: files included from the FIFE root src directory -// Second block: files included from the same folder -#include "view/rendererbase.h" - -namespace FIFE { - class RenderBackend; - class AbstractFont; - - class GeometricRenderer: public RendererBase { - public: - /** constructor. - * @param renderbackend to use - * @param position position for this renderer in rendering pipeline - */ - GeometricRenderer(RenderBackend* renderbackend, int position); - - GeometricRenderer(const GeometricRenderer& old); - - RendererBase* clone(); - - /** Destructor. - */ - virtual ~GeometricRenderer(); - void render(Camera* cam, Layer* layer, std::vector<Instance*>& instances); - std::string getName() { return "GeometricRenderer"; } - - /** Adds a line to be drawed - */ - void addLine(Point p1, Point p2, int r, int g, int b); - - /** Removes all lines - */ - void removeAllLines(); - - /** Gets instance for interface access - */ - static GeometricRenderer* getInstance(IRendererContainer* cnt); - - private: - // contains per-instance information for overlay drawing - class LineInfo { - public: - Point p1; - Point p2; - uint8_t r; - uint8_t g; - uint8_t b; - LineInfo(Point p1, Point p2, int r, int g, int b); - }; - std::vector<LineInfo> m_lines; - }; - -} - -#endif
--- a/engine/core/view/renderers/geometricrenderer.i Fri Jul 11 14:35:31 2008 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -%module fife -%{ -#include "view/renderers/geometricrenderer.h" -%} - -namespace FIFE { - class RenderBackend; - - class GeometricRenderer: public RendererBase { - public: - virtual ~GeometricRenderer(); - std::string getName(); - void addLine(Point p1, Point p2, int r, int g, int b); - void removeAllLines(); - static GeometricRenderer* getInstance(IRendererContainer* cnt); - private: - GeometricRenderer(RenderBackend* renderbackend, int position); - }; -}