annotate engine/core/view/renderers/gridrenderer.cpp @ 680:60621d858548

* Fixed the image/animation functions in GenericRenderer and LightRenderer. The functions now consider the camera zoom level. * Added the forgotten LightEdit plugin for the editor.
author helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
date Sun, 21 Nov 2010 15:58:14 +0000
parents e3140f01749d
children
rev   line source
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
1 /***************************************************************************
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
2 * Copyright (C) 2005-2008 by the FIFE team *
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
3 * http://www.fifengine.de *
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
4 * This file is part of FIFE. *
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
5 * *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
6 * FIFE is free software; you can redistribute it and/or *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
7 * modify it under the terms of the GNU Lesser General Public *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
8 * License as published by the Free Software Foundation; either *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
9 * version 2.1 of the License, or (at your option) any later version. *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
10 * *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
11 * This library is distributed in the hope that it will be useful, *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
14 * Lesser General Public License for more details. *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
15 * *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
16 * You should have received a copy of the GNU Lesser General Public *
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
17 * License along with this library; if not, write to the *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
18 * Free Software Foundation, Inc., *
46
90005975cdbb * Final LGPL switch step by adjusting the file headers
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 0
diff changeset
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
20 ***************************************************************************/
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
21
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
22 // Standard C++ library includes
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
23
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
24 // 3rd party library includes
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
25
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
26 // FIFE includes
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
27 // These includes are split up in two parts, separated by one empty line
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
28 // First block: files included from the FIFE root src directory
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
29 // Second block: files included from the same folder
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
30 #include "video/renderbackend.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
31 #include "util/math/fife_math.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
32 #include "util/log/logger.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
33 #include "model/metamodel/grids/cellgrid.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
34 #include "model/structures/instance.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
35 #include "model/structures/layer.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
36 #include "model/structures/location.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
37
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
38 #include "view/camera.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
39 #include "gridrenderer.h"
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
40
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
41
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
42 namespace FIFE {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
43 static Logger _log(LM_VIEWVIEW);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
44
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
45 GridRenderer::GridRenderer(RenderBackend* renderbackend, int position):
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
46 RendererBase(renderbackend, position) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
47 setEnabled(false);
579
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
48 m_color.r = 0;
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
49 m_color.g = 255;
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
50 m_color.b = 0;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
51 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
52
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
53 GridRenderer::GridRenderer(const GridRenderer& old):
579
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
54 RendererBase(old),
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
55 m_color(old.m_color) {
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
56 setEnabled(false);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
57 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
58
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
59 RendererBase* GridRenderer::clone() {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
60 return new GridRenderer(*this);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
61 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
62
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
63 GridRenderer::~GridRenderer() {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
64 }
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
65
579
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
66 GridRenderer* GridRenderer::getInstance(IRendererContainer* cnt) {
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
67 return dynamic_cast<GridRenderer*>(cnt->getRenderer("GridRenderer"));
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
68 }
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
69
482
16c2b3ee59ce * Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
70 void GridRenderer::render(Camera* cam, Layer* layer, RenderList& instances) {
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
71 CellGrid* cg = layer->getCellGrid();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
72 if (!cg) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
73 FL_WARN(_log, "No cellgrid assigned to layer, cannot draw grid");
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
74 return;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
75 }
661
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 579
diff changeset
76 m_renderbackend->disableLighting();
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
77 //
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
78 //
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
79 // //render elev_coord box
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
80 // //draw front quad
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
81 // // 1,1,1
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
82 // //1,-1,1
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
83 // //-1,-1,1
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
84 // //-1,1,1
579
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
85 //We don't need the elevation box atm
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
86 // Point a,b,c,d;
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
87 //
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
88 //
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
89 // ScreenPoint copt1 =cam->toScreenCoordinates(ExactModelCoordinate(1,1,1) );
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
90 // ScreenPoint copt2 =cam->toScreenCoordinates(ExactModelCoordinate(1,-1,1) );
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
91 // Point coptt1(copt1.x,copt1.y);
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
92 // Point coptt2(copt2.x,copt2.y);
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
93 // m_renderbackend->drawLine(coptt1,coptt2 ,15, 15, 200);
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
94 // a = coptt1;
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
95 //
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
96 // copt1 =cam->toScreenCoordinates(ExactModelCoordinate(1,-1,1) );
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
97 // copt2 =cam->toScreenCoordinates(ExactModelCoordinate(-1,-1,1) );
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
98 // coptt1 = Point(copt1.x,copt1.y);
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
99 // coptt2 = Point(copt2.x,copt2.y);
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
100 // m_renderbackend->drawLine(coptt1,coptt2 ,15, 15, 200);
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
101 // b = coptt1;
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
102 //
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
103 // copt1 =cam->toScreenCoordinates(ExactModelCoordinate(-1,-1,1) );
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
104 // copt2 =cam->toScreenCoordinates(ExactModelCoordinate(-1,1,1) );
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
105 // coptt1 = Point(copt1.x,copt1.y);
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
106 // coptt2 = Point(copt2.x,copt2.y);
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
107 // m_renderbackend->drawLine(coptt1,coptt2 ,15, 15, 200);
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
108 // c = coptt1;
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
109 //
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
110 // copt1 =cam->toScreenCoordinates(ExactModelCoordinate(-1,1,1) );
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
111 // copt2 =cam->toScreenCoordinates(ExactModelCoordinate(1,1,1) );
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
112 // coptt1 = Point(copt1.x,copt1.y);
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
113 // coptt2 = Point(copt2.x,copt2.y);
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
114 // m_renderbackend->drawLine(coptt1,coptt2 ,15, 15, 20);
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
115 // d = coptt1;
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
116 //
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
117 // m_renderbackend->drawQuad(a,b,c,d,15, 15, 200);
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
118 //
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
119 //
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
120 // //draw back quad
579
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
121 // copt1 =cam->toScreenCoordinates(ExactModelCoordinate(-1,-1,-1) );
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
122 // copt2 =cam->toScreenCoordinates(ExactModelCoordinate(-1,1,-1) );
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
123 // coptt1 = Point(copt1.x,copt1.y);
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
124 // coptt2 = Point(copt2.x,copt2.y);
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
125 // m_renderbackend->drawLine(coptt1,coptt2 ,200, 200, 200);
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
126 //
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
127 // copt1 =cam->toScreenCoordinates(ExactModelCoordinate(-1,1,-1) );
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
128 // copt2 =cam->toScreenCoordinates(ExactModelCoordinate(1,1,-1) );
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
129 // coptt1 = Point(copt1.x,copt1.y);
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
130 // coptt2 = Point(copt2.x,copt2.y);
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
131 // m_renderbackend->drawLine(coptt1,coptt2 ,200, 200, 200);
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
132 //
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
133 // copt1 =cam->toScreenCoordinates(ExactModelCoordinate(1,1,-1) );
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
134 // copt2 =cam->toScreenCoordinates(ExactModelCoordinate(1,-1,-1) );
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
135 // coptt1 = Point(copt1.x,copt1.y);
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
136 // coptt2 = Point(copt2.x,copt2.y);
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
137 // m_renderbackend->drawLine(coptt1,coptt2 ,200, 200, 200);
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
138 //
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
139 // copt1 =cam->toScreenCoordinates(ExactModelCoordinate(1,-1,-1) );
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
140 // copt2 =cam->toScreenCoordinates(ExactModelCoordinate(-1,-1,-1) );
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
141 // coptt1 = Point(copt1.x,copt1.y);
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
142 // coptt2 = Point(copt2.x,copt2.y);
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
143 // m_renderbackend->drawLine(coptt1,coptt2 ,200, 200, 200);
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
144
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
145
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
146 Rect cv = cam->getViewPort();
579
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
147 int cvx2 = cv.x+cv.w;
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
148 int cvy2 = cv.y+cv.h;
482
16c2b3ee59ce * Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
149 RenderList::const_iterator instance_it = instances.begin();
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
150 for (;instance_it != instances.end(); ++instance_it) {
482
16c2b3ee59ce * Merged the view performance branch back into trunk. fixes[ticket:419]
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 46
diff changeset
151 Instance* instance = (*instance_it)->instance;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
152 std::vector<ExactModelCoordinate> vertices;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
153 cg->getVertices(vertices, instance->getLocationRef().getLayerCoordinates());
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
154 std::vector<ExactModelCoordinate>::const_iterator it = vertices.begin();
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
155 ScreenPoint firstpt = cam->toScreenCoordinates(cg->toMapCoordinates(*it));
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
156 Point pt1(firstpt.x, firstpt.y);
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
157 Point pt2;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
158 ++it;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
159 for (; it != vertices.end(); it++) {
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
160 ScreenPoint pts = cam->toScreenCoordinates(cg->toMapCoordinates(*it));
579
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
161 pt2.x = pts.x;
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
162 pt2.y = pts.y;
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
163 Point cpt1 = pt1;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
164 Point cpt2 = pt2;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
165
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
166 if (cpt1.x < cv.x) cpt1.x = cv.x;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
167 if (cpt2.x < cv.x) cpt2.x = cv.x;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
168 if (cpt1.y < cv.y) cpt1.y = cv.y;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
169 if (cpt2.y < cv.y) cpt2.y = cv.y;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
170 if (cpt1.x > cvx2) cpt1.x = cvx2;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
171 if (cpt2.x > cvx2) cpt2.x = cvx2;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
172 if (cpt1.y > cvy2) cpt1.y = cvy2;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
173 if (cpt2.y > cvy2) cpt2.y = cvy2;
579
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
174
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
175 m_renderbackend->drawLine(cpt1, cpt2, m_color.r, m_color.g, m_color.b);
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
176 pt1 = pt2;
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
177 }
579
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
178 if ((pt2.x >= cv.x) && (pt2.x <= cvx2) && (pt2.y >= cv.y) && (pt2.y <= cvy2)) {
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
179 if ((firstpt.x >= cv.x) && (firstpt.x <= cvx2) && (firstpt.y >= cv.y) && (firstpt.y <= cvy2)) {
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
180 m_renderbackend->drawLine(pt2, Point(firstpt.x, firstpt.y), m_color.r, m_color.g, m_color.b);
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
181 }
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
182 }
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
183 }
661
e3140f01749d * Merged the light branch back into trunk.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 579
diff changeset
184 m_renderbackend->enableLighting();
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
185 }
579
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
186
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
187 void GridRenderer::setColor(Uint8 r, Uint8 g, Uint8 b) {
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
188 m_color.r = r;
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
189 m_color.g = g;
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
190 m_color.b = b;
b2feacaed53c * Added the colorbuffer patch with a small change due to SDL. Performance boost between 20-30% under OpenGL.
helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 482
diff changeset
191 }
0
4a0efb7baf70 * Datasets becomes the new trunk and retires after that :-)
mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
192 }