comparison engine/core/view/renderers/genericrenderer.cpp @ 430:ad1f09d954f9

Added the ability to render a vertex on the screen. The vertex is represented by a small square. fixes[t:455]
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Tue, 23 Feb 2010 19:25:59 +0000
parents 56ac89189bc4
children f855809822cf
comparison
equal deleted inserted replaced
429:be291458d9b5 430:ad1f09d954f9
194 void GenericRendererLineInfo::render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) { 194 void GenericRendererLineInfo::render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) {
195 Point p1 = m_edge1.getCalculatedPoint(cam, layer, instances); 195 Point p1 = m_edge1.getCalculatedPoint(cam, layer, instances);
196 Point p2 = m_edge2.getCalculatedPoint(cam, layer, instances); 196 Point p2 = m_edge2.getCalculatedPoint(cam, layer, instances);
197 renderbackend->drawLine(p1, p2, m_red, m_green, m_blue); 197 renderbackend->drawLine(p1, p2, m_red, m_green, m_blue);
198 } 198 }
199 199
200 GenericRendererPointInfo::GenericRendererPointInfo(GenericRendererNode anchor, uint8_t r, uint8_t g, uint8_t b): 200 GenericRendererPointInfo::GenericRendererPointInfo(GenericRendererNode anchor, uint8_t r, uint8_t g, uint8_t b):
201 GenericRendererElementInfo(), 201 GenericRendererElementInfo(),
202 m_anchor(anchor), 202 m_anchor(anchor),
203 m_red(r), 203 m_red(r),
204 m_green(g), 204 m_green(g),
206 } 206 }
207 void GenericRendererPointInfo::render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) { 207 void GenericRendererPointInfo::render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) {
208 Point p = m_anchor.getCalculatedPoint(cam, layer, instances); 208 Point p = m_anchor.getCalculatedPoint(cam, layer, instances);
209 renderbackend->putPixel(p.x, p.y, m_red, m_green, m_blue); 209 renderbackend->putPixel(p.x, p.y, m_red, m_green, m_blue);
210 } 210 }
211 211
212 GenericRendererQuadInfo::GenericRendererQuadInfo(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b): 212 GenericRendererQuadInfo::GenericRendererQuadInfo(GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b):
213 GenericRendererElementInfo(), 213 GenericRendererElementInfo(),
214 m_edge1(n1), 214 m_edge1(n1),
215 m_edge2(n2), 215 m_edge2(n2),
216 m_edge3(n3), 216 m_edge3(n3),
224 Point p2 = m_edge2.getCalculatedPoint(cam, layer, instances); 224 Point p2 = m_edge2.getCalculatedPoint(cam, layer, instances);
225 Point p3 = m_edge3.getCalculatedPoint(cam, layer, instances); 225 Point p3 = m_edge3.getCalculatedPoint(cam, layer, instances);
226 Point p4 = m_edge4.getCalculatedPoint(cam, layer, instances); 226 Point p4 = m_edge4.getCalculatedPoint(cam, layer, instances);
227 renderbackend->drawQuad(p1, p2, p3, p4, m_red, m_green, m_blue); 227 renderbackend->drawQuad(p1, p2, p3, p4, m_red, m_green, m_blue);
228 } 228 }
229 229
230 GenericRendererVertexInfo::GenericRendererVertexInfo(GenericRendererNode center, int size, uint8_t r, uint8_t g, uint8_t b):
231 GenericRendererElementInfo(),
232 m_center(center),
233 m_size(size),
234 m_red(r),
235 m_green(g),
236 m_blue(b) {
237 }
238 void GenericRendererVertexInfo::render(Camera* cam, Layer* layer, std::vector<Instance*>& instances, RenderBackend* renderbackend, ImagePool* imagepool, AnimationPool* animpool) {
239 Point p = m_center.getCalculatedPoint(cam, layer, instances);
240 renderbackend->drawVertex(p, m_size, m_red, m_green, m_blue);
241 }
242
230 GenericRendererImageInfo::GenericRendererImageInfo(GenericRendererNode anchor, int image): 243 GenericRendererImageInfo::GenericRendererImageInfo(GenericRendererNode anchor, int image):
231 GenericRendererElementInfo(), 244 GenericRendererElementInfo(),
232 m_anchor(anchor), 245 m_anchor(anchor),
233 m_image(image) { 246 m_image(image) {
234 } 247 }
240 r.y = p.y-img->getHeight()/2; 253 r.y = p.y-img->getHeight()/2;
241 r.w = img->getWidth(); 254 r.w = img->getWidth();
242 r.h = img->getHeight(); 255 r.h = img->getHeight();
243 img->render(r); 256 img->render(r);
244 } 257 }
245 258
246 GenericRendererAnimationInfo::GenericRendererAnimationInfo(GenericRendererNode anchor, int animation): 259 GenericRendererAnimationInfo::GenericRendererAnimationInfo(GenericRendererNode anchor, int animation):
247 GenericRendererElementInfo(), 260 GenericRendererElementInfo(),
248 m_anchor(anchor), 261 m_anchor(anchor),
249 m_animation(animation), 262 m_animation(animation),
250 m_start_time(TimeManager::instance()->getTime()), 263 m_start_time(TimeManager::instance()->getTime()),
260 r.y = p.y-img->getHeight()/2; 273 r.y = p.y-img->getHeight()/2;
261 r.w = img->getWidth(); 274 r.w = img->getWidth();
262 r.h = img->getHeight(); 275 r.h = img->getHeight();
263 img->render(r); 276 img->render(r);
264 } 277 }
265 278
266 GenericRendererTextInfo::GenericRendererTextInfo(GenericRendererNode anchor, AbstractFont* font, std::string text): 279 GenericRendererTextInfo::GenericRendererTextInfo(GenericRendererNode anchor, AbstractFont* font, std::string text):
267 GenericRendererElementInfo(), 280 GenericRendererElementInfo(),
268 m_anchor(anchor), 281 m_anchor(anchor),
269 m_font(font), 282 m_font(font),
270 m_text(text) { 283 m_text(text) {
277 r.y = p.y-img->getHeight()/2; 290 r.y = p.y-img->getHeight()/2;
278 r.w = img->getWidth(); 291 r.w = img->getWidth();
279 r.h = img->getHeight(); 292 r.h = img->getHeight();
280 img->render(r); 293 img->render(r);
281 } 294 }
282 295
283 GenericRenderer* GenericRenderer::getInstance(IRendererContainer* cnt) { 296 GenericRenderer* GenericRenderer::getInstance(IRendererContainer* cnt) {
284 return dynamic_cast<GenericRenderer*>(cnt->getRenderer("GenericRenderer")); 297 return dynamic_cast<GenericRenderer*>(cnt->getRenderer("GenericRenderer"));
285 } 298 }
286 299
287 GenericRenderer::GenericRenderer(RenderBackend* renderbackend, int position, ImagePool* imagepool, AnimationPool* animpool): 300 GenericRenderer::GenericRenderer(RenderBackend* renderbackend, int position, ImagePool* imagepool, AnimationPool* animpool):
288 RendererBase(renderbackend, position), 301 RendererBase(renderbackend, position),
289 m_imagepool(imagepool), 302 m_imagepool(imagepool),
290 m_animationpool(animpool), 303 m_animationpool(animpool),
291 m_groups() { 304 m_groups() {
316 } 329 }
317 void GenericRenderer::addQuad(const std::string &group, GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b) { 330 void GenericRenderer::addQuad(const std::string &group, GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b) {
318 GenericRendererElementInfo* info = new GenericRendererQuadInfo(n1, n2, n3, n4, r, g, b); 331 GenericRendererElementInfo* info = new GenericRendererQuadInfo(n1, n2, n3, n4, r, g, b);
319 m_groups[group].push_back(info); 332 m_groups[group].push_back(info);
320 } 333 }
334 void GenericRenderer::addVertex(const std::string &group, GenericRendererNode n, int size, uint8_t r, uint8_t g, uint8_t b) {
335 GenericRendererElementInfo* info = new GenericRendererVertexInfo(n, size, r, g, b);
336 m_groups[group].push_back(info);
337 }
321 void GenericRenderer::addText(const std::string &group, GenericRendererNode n, AbstractFont* font, const std::string &text) { 338 void GenericRenderer::addText(const std::string &group, GenericRendererNode n, AbstractFont* font, const std::string &text) {
322 GenericRendererElementInfo* info = new GenericRendererTextInfo(n, font, text); 339 GenericRendererElementInfo* info = new GenericRendererTextInfo(n, font, text);
323 m_groups[group].push_back(info); 340 m_groups[group].push_back(info);
324 } 341 }
325 void GenericRenderer::addImage(const std::string &group, GenericRendererNode n, int image) { 342 void GenericRenderer::addImage(const std::string &group, GenericRendererNode n, int image) {
328 } 345 }
329 void GenericRenderer::addAnimation(const std::string &group, GenericRendererNode n, int animation) { 346 void GenericRenderer::addAnimation(const std::string &group, GenericRendererNode n, int animation) {
330 GenericRendererElementInfo* info = new GenericRendererAnimationInfo(n, animation); 347 GenericRendererElementInfo* info = new GenericRendererAnimationInfo(n, animation);
331 m_groups[group].push_back(info); 348 m_groups[group].push_back(info);
332 } 349 }
350
333 void GenericRenderer::removeAll(const std::string &group) { 351 void GenericRenderer::removeAll(const std::string &group) {
334 std::vector<GenericRendererElementInfo*>::const_iterator info_it = m_groups[group].begin(); 352 std::vector<GenericRendererElementInfo*>::const_iterator info_it = m_groups[group].begin();
335 for (;info_it != m_groups[group].end(); ++info_it) { 353 for (;info_it != m_groups[group].end(); ++info_it) {
336 delete *info_it; 354 delete *info_it;
337 } 355 }