Mercurial > fife-parpg
comparison engine/core/view/renderers/geometricrenderer.cpp @ 17:ae46cee19e76
- add geometric renderer, can currently only draw liens.
- thanks to l4rs for some help
author | spq@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Mon, 07 Jul 2008 00:27:59 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
16:ca21a01f5b1e | 17:ae46cee19e76 |
---|---|
1 /*************************************************************************** | |
2 * Copyright (C) 2005-2008 by the FIFE team * | |
3 * http://www.fifengine.de * | |
4 * This file is part of FIFE. * | |
5 * * | |
6 * FIFE is free software; you can redistribute it and/or modify * | |
7 * it under the terms of the GNU General Public License as published by * | |
8 * the Free Software Foundation; either version 2 of the License, or * | |
9 * (at your option) any later version. * | |
10 * * | |
11 * This program is distributed in the hope that it will be useful, * | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
14 * GNU General Public License for more details. * | |
15 * * | |
16 * You should have received a copy of the GNU General Public License * | |
17 * along with this program; if not, write to the * | |
18 * Free Software Foundation, Inc., * | |
19 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * | |
20 ***************************************************************************/ | |
21 | |
22 // Standard C++ library includes | |
23 | |
24 // 3rd party library includes | |
25 | |
26 // FIFE includes | |
27 // These includes are split up in two parts, separated by one empty line | |
28 // First block: files included from the FIFE root src directory | |
29 // Second block: files included from the same folder | |
30 #include "video/renderbackend.h" | |
31 #include "util/math/fife_math.h" | |
32 #include "util/log/logger.h" | |
33 #include "model/metamodel/grids/cellgrid.h" | |
34 #include "model/structures/instance.h" | |
35 #include "model/structures/layer.h" | |
36 #include "model/structures/location.h" | |
37 | |
38 #include "view/camera.h" | |
39 #include "geometricrenderer.h" | |
40 | |
41 | |
42 namespace FIFE { | |
43 static Logger _log(LM_VIEWVIEW); | |
44 GeometricRenderer::LineInfo::LineInfo(Point p1, Point p2, int r, int g, int b): | |
45 p1(p1), | |
46 p2(p2), | |
47 r(r), | |
48 g(g), | |
49 b(b) { | |
50 } | |
51 | |
52 GeometricRenderer* GeometricRenderer::getInstance(IRendererContainer* cnt) { | |
53 return dynamic_cast<GeometricRenderer*>(cnt->getRenderer("GeometricRenderer")); | |
54 } | |
55 | |
56 GeometricRenderer::GeometricRenderer(RenderBackend* renderbackend, int position): | |
57 RendererBase(renderbackend, position), | |
58 m_lines() { | |
59 setEnabled(false); | |
60 } | |
61 | |
62 GeometricRenderer::GeometricRenderer(const GeometricRenderer& old): | |
63 RendererBase(old) { | |
64 setEnabled(false); | |
65 } | |
66 | |
67 RendererBase* GeometricRenderer::clone() { | |
68 return new GeometricRenderer(*this); | |
69 } | |
70 | |
71 GeometricRenderer::~GeometricRenderer() { | |
72 } | |
73 | |
74 void GeometricRenderer::addLine(Point p1, Point p2, int r, int g, int b) { | |
75 LineInfo info(p1, p2, r, g, b); | |
76 m_lines.push_back(info); | |
77 } | |
78 | |
79 void GeometricRenderer::removeAllLines() { | |
80 m_lines.clear(); | |
81 } | |
82 | |
83 void GeometricRenderer::render(Camera* cam, Layer* layer, std::vector<Instance*>& instances) { | |
84 std::vector<LineInfo>::const_iterator lineinfo_it = m_lines.begin(); | |
85 for (;lineinfo_it != m_lines.end(); ++lineinfo_it) { | |
86 LineInfo info = *lineinfo_it; | |
87 m_renderbackend->drawLine(info.p1, info.p2, info.r, info.g, info.b); | |
88 } | |
89 } | |
90 } |