annotate engine/core/view/renderers/genericrenderer.cpp @ 25:fc6713d72b80

add setter for nodes
author spq@33b003aa-7bff-0310-803a-e67f0ece8222
date Fri, 11 Jul 2008 11:25:11 +0000
parents cb87d40e9342
children 70f41ea8e7db
rev   line source
23
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
1 /***************************************************************************
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
2 * Copyright (C) 2005-2008 by the FIFE team *
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
3 * http://www.fifengine.de *
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
4 * This file is part of FIFE. *
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
5 * *
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
6 * FIFE is free software; you can redistribute it and/or modify *
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by *
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or *
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
9 * (at your option) any later version. *
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
10 * *
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful, *
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
14 * GNU General Public License for more details. *
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
15 * *
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License *
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
17 * along with this program; if not, write to the *
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
18 * Free Software Foundation, Inc., *
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
19 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
20 ***************************************************************************/
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
21
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
22 // Standard C++ library includes
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
23
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
24 // 3rd party library includes
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
25
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
26 // FIFE includes
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
27 // These includes are split up in two parts, separated by one empty line
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
28 // First block: files included from the FIFE root src directory
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
29 // Second block: files included from the same folder
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
30 #include "video/renderbackend.h"
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
31 #include "util/math/fife_math.h"
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
32 #include "util/log/logger.h"
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
33 #include "model/metamodel/grids/cellgrid.h"
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
34 #include "model/structures/instance.h"
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
35 #include "model/structures/layer.h"
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
36 #include "model/structures/location.h"
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
37
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
38 #include "view/camera.h"
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
39 #include "genericrenderer.h"
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
40
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
41
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
42 namespace FIFE {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
43 static Logger _log(LM_VIEWVIEW);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
44
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
45 GenericRendererNode::GenericRendererNode(Instance* attached_instance, Location* relative_location, const Point &relative_point):
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
46 m_instance(attached_instance),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
47 m_location(relative_location),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
48 m_point(relative_point) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
49 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
50 GenericRendererNode::GenericRendererNode(Instance* attached_instance, const Point &relative_point):
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
51 m_instance(attached_instance),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
52 m_location(NULL),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
53 m_point(relative_point) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
54 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
55 GenericRendererNode::GenericRendererNode(Location* attached_location, const Point &relative_point):
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
56 m_instance(NULL),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
57 m_location(attached_location),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
58 m_point(relative_point) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
59 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
60 GenericRendererNode::GenericRendererNode(const Point &attached_point):
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
61 m_instance(NULL),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
62 m_location(NULL),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
63 m_point(attached_point) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
64 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
65 GenericRendererNode::~GenericRendererNode() {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
66 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
67
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
68 void GenericRendererNode::setAttached(Instance* attached_instance, const Location &relative_location, const Point &relative_point) {
25
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
69 m_instance = attached_instance;
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
70 m_location = relative_location;
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
71 m_point = relative_point;
23
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
72 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
73 void GenericRendererNode::setAttached(Instance* attached_instance, const Location &relative_location) {
25
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
74 m_instance = attached_instance;
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
75 m_location = relative_location;
23
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
76 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
77 void GenericRendererNode::setAttached(Instance* attached_instance, const Point &relative_point) {
25
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
78 m_instance = attached_instance;
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
79 m_point = relative_point;
23
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
80 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
81 void GenericRendererNode::setAttached(Instance* attached_instance) {
25
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
82 m_instance = attached_instance;
23
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
83 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
84 void GenericRendererNode::setAttached(const Location &attached_location, const Point &relative_point) {
25
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
85 m_instance = NULL;
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
86 m_location = attached_location;
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
87 m_point = relative_point;
23
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
88 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
89 void GenericRendererNode::setAttached(const Location &attached_location) {
25
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
90 m_instance = NULL;
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
91 m_location = attached_location;
23
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
92 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
93 void GenericRendererNode::setAttached(const Point &attached_point) {
25
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
94 m_instance = NULL;
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
95 m_location = NULL;
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
96 m_point = attached_point;
23
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
97 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
98
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
99 void GenericRendererNode::setRelative(const Location &relative_location) {
25
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
100 if(m_instance == NULL) {
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
101 throw NotSupported("No instance attached.");
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
102 }
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
103 m_location = relative_location;
23
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
104 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
105 void GenericRendererNode::setRelative(const Location &relative_location, Point relative_point) {
25
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
106 if(m_instance == NULL) {
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
107 throw NotSupported("No instance attached.");
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
108 }
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
109 m_location = relative_location;
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
110 m_point = relative_point;
23
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
111 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
112 void GenericRendererNode::setRelative(const Point &relative_point) {
25
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
113 if(m_instance == NULL or m_location == NULL) {
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
114 throw NotSupported("No instance or location attached.");
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
115 }
fc6713d72b80 add setter for nodes
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 24
diff changeset
116 m_point = relative_point;
23
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
117 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
118
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
119 Instance* GenericRendererNode::getAttachedInstance() {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
120 if(m_instance == NULL) {
24
cb87d40e9342 fix exceptions and cleanup code
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 23
diff changeset
121 throw NotSupported("No instance attached.");
23
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
122 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
123 return m_instance;
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
124 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
125 Location* GenericRendererNode::getAttachedLocation() {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
126 if(m_instance != NULL or m_location == NULL) {
24
cb87d40e9342 fix exceptions and cleanup code
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 23
diff changeset
127 throw NotSupported("No location attached.");
23
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
128 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
129 return m_location;
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
130 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
131 Point GenericRendererNode::getAttachedPoint() {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
132 if(m_instance != NULL or m_location != NULL) {
24
cb87d40e9342 fix exceptions and cleanup code
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 23
diff changeset
133 throw NotSupported("No point attached.");
23
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
134 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
135 return m_point;
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
136 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
137
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
138 Location* GenericRendererNode::getOffsetLocation() {
24
cb87d40e9342 fix exceptions and cleanup code
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 23
diff changeset
139 if(m_instance == NULL or m_location == NULL) {
cb87d40e9342 fix exceptions and cleanup code
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 23
diff changeset
140 throw NotSupported("No location as offset used.");
23
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
141 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
142 return m_location;
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
143 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
144 Point GenericRendererNode::getOffsetPoint() {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
145 if(m_instance == NULL and m_location == NULL) {
24
cb87d40e9342 fix exceptions and cleanup code
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 23
diff changeset
146 throw NotSupported("No point as offset used.");
23
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
147 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
148 return m_point;
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
149 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
150
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
151 Instance* GenericRendererNode::getInstance() {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
152 return m_instance;
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
153 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
154 Location* GenericRendererNode::getLocation() {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
155 return m_location;
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
156 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
157 Point GenericRendererNode::getPoint() {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
158 return m_point;
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
159 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
160
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
161 Point GenericRendererNode::getCalculatedPoint(Camera* cam, Layer* layer, std::vector<Instance*>& instances) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
162 ScreenPoint p;
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
163 if(m_instance != NULL) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
164 if(m_location != NULL) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
165 p = cam->toScreenCoordinates(m_instance->getLocationRef().getMapCoordinates() + m_location->getMapCoordinates());
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
166 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
167 else {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
168 p = cam->toScreenCoordinates(m_instance->getLocation().getMapCoordinates());
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
169 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
170 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
171 else if(m_location != NULL) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
172 p = cam->toScreenCoordinates(m_location->getMapCoordinates());
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
173 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
174 else
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
175 return m_point;
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
176 return Point(m_point.x + p.x, m_point.y + p.y);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
177 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
178
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
179 GenericRendererLineInfo::GenericRendererLineInfo(GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b):
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
180 GenericRendererElementInfo(),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
181 n1(n1),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
182 n2(n2),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
183 r(r),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
184 g(g),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
185 b(b) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
186 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
187 void GenericRendererLineInfo::render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
188 Point p1 = n1.getCalculatedPoint(cam, layer, instances);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
189 Point p2 = n2.getCalculatedPoint(cam, layer, instances);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
190 renderbackend->drawLine(p1, p2, r, g, b);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
191 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
192
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
193 GenericRendererPointInfo::GenericRendererPointInfo(GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b):
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
194 GenericRendererElementInfo(),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
195 n(n),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
196 r(r),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
197 g(g),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
198 b(b) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
199 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
200 void GenericRendererPointInfo::render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
201 Point p = n.getCalculatedPoint(cam, layer, instances);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
202 renderbackend->putPixel(p.x, p.y, r, g, b);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
203 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
204
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
205 GenericRendererQuadInfo::GenericRendererQuadInfo(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b):
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
206 GenericRendererElementInfo(),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
207 n1(n1),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
208 n2(n2),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
209 n3(n3),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
210 n4(n4),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
211 r(r),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
212 g(g),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
213 b(b) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
214 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
215 void GenericRendererQuadInfo::render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
216 Point p1 = n1.getCalculatedPoint(cam, layer, instances);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
217 Point p2 = n2.getCalculatedPoint(cam, layer, instances);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
218 Point p3 = n3.getCalculatedPoint(cam, layer, instances);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
219 Point p4 = n4.getCalculatedPoint(cam, layer, instances);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
220 renderbackend->drawQuad(p1, p2, p3, p4, r, g, b);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
221 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
222
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
223 GenericRendererImageInfo::GenericRendererImageInfo(GenericRendererNode n, int image):
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
224 GenericRendererElementInfo(),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
225 n(n),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
226 image(image) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
227 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
228 void GenericRendererImageInfo::render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
229 return;
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
230 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
231
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
232 GenericRendererAnimationInfo::GenericRendererAnimationInfo(GenericRendererNode n, int animation):
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
233 GenericRendererElementInfo(),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
234 n(n),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
235 animation(animation) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
236 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
237 void GenericRendererAnimationInfo::render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
238 return;
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
239 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
240
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
241 GenericRendererTextInfo::GenericRendererTextInfo(GenericRendererNode n, AbstractFont* font, std::string text):
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
242 GenericRendererElementInfo(),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
243 n(n),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
244 font(font),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
245 text(text) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
246 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
247 void GenericRendererTextInfo::render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
248 return;
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
249 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
250
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
251 GenericRenderer* GenericRenderer::getInstance(IRendererContainer* cnt) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
252 return dynamic_cast<GenericRenderer*>(cnt->getRenderer("GenericRenderer"));
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
253 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
254
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
255 GenericRenderer::GenericRenderer(RenderBackend* renderbackend, int position):
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
256 RendererBase(renderbackend, position),
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
257 m_infos() {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
258 setEnabled(false);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
259 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
260
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
261 GenericRenderer::GenericRenderer(const GenericRenderer& old):
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
262 RendererBase(old) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
263 setEnabled(false);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
264 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
265
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
266 RendererBase* GenericRenderer::clone() {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
267 return new GenericRenderer(*this);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
268 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
269
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
270 GenericRenderer::~GenericRenderer() {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
271 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
272 void GenericRenderer::addLine(GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
273 GenericRendererElementInfo* info = new GenericRendererLineInfo(n1, n2, r, g, b);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
274 m_infos.push_back(info);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
275 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
276 void GenericRenderer::addPoint(GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
277 GenericRendererElementInfo* info = new GenericRendererPointInfo(n, r, g, b);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
278 m_infos.push_back(info);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
279 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
280 void GenericRenderer::addQuad(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
281 GenericRendererElementInfo* info = new GenericRendererQuadInfo(n1, n2, n3, n4, r, g, b);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
282 m_infos.push_back(info);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
283 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
284 void GenericRenderer::addText(GenericRendererNode n, AbstractFont* font, std::string text) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
285 GenericRendererElementInfo* info = new GenericRendererTextInfo(n, font, text);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
286 m_infos.push_back(info);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
287 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
288 void GenericRenderer::addImage(GenericRendererNode n, int image) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
289 GenericRendererElementInfo* info = new GenericRendererImageInfo(n, image);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
290 m_infos.push_back(info);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
291 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
292 void GenericRenderer::addAnimation(GenericRendererNode n, int animation) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
293 GenericRendererElementInfo* info = new GenericRendererAnimationInfo(n, animation);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
294 m_infos.push_back(info);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
295 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
296 void GenericRenderer::removeAll() {
24
cb87d40e9342 fix exceptions and cleanup code
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 23
diff changeset
297 std::vector<GenericRendererElementInfo*>::const_iterator info_it = m_infos.begin();
cb87d40e9342 fix exceptions and cleanup code
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 23
diff changeset
298 for (;info_it != m_infos.end(); ++info_it) {
cb87d40e9342 fix exceptions and cleanup code
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 23
diff changeset
299 delete *info_it;
cb87d40e9342 fix exceptions and cleanup code
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 23
diff changeset
300 }
23
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
301 m_infos.clear();
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
302 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
303
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
304 void GenericRenderer::render(Camera* cam, Layer* layer, std::vector<Instance*>& instances) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
305 std::vector<GenericRendererElementInfo*>::const_iterator info_it = m_infos.begin();
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
306 for (;info_it != m_infos.end(); ++info_it) {
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
307 GenericRendererElementInfo* info = *info_it;
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
308 info->render(cam, layer, instances, m_renderbackend);
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
309 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
310 }
e5e2fec68834 add generic renderer
spq@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
311 }