Mercurial > fife-parpg
comparison engine/core/view/renderers/genericrenderer.cpp @ 105:2241b0d5379e
use strings as grouping in generic renderer, easier for the clients...
author | spq@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Thu, 24 Jul 2008 13:20:39 +0000 |
parents | 90005975cdbb |
children | 56ac89189bc4 |
comparison
equal
deleted
inserted
replaced
104:2c7101e4d81d | 105:2241b0d5379e |
---|---|
303 return new GenericRenderer(*this); | 303 return new GenericRenderer(*this); |
304 } | 304 } |
305 | 305 |
306 GenericRenderer::~GenericRenderer() { | 306 GenericRenderer::~GenericRenderer() { |
307 } | 307 } |
308 void GenericRenderer::addLine(int group, GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b) { | 308 void GenericRenderer::addLine(const std::string &group, GenericRendererNode n1, GenericRendererNode n2, uint8_t r, uint8_t g, uint8_t b) { |
309 GenericRendererElementInfo* info = new GenericRendererLineInfo(n1, n2, r, g, b); | 309 GenericRendererElementInfo* info = new GenericRendererLineInfo(n1, n2, r, g, b); |
310 m_groups[group].push_back(info); | 310 m_groups[group].push_back(info); |
311 } | 311 } |
312 void GenericRenderer::addPoint(int group, GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b) { | 312 void GenericRenderer::addPoint(const std::string &group, GenericRendererNode n, uint8_t r, uint8_t g, uint8_t b) { |
313 GenericRendererElementInfo* info = new GenericRendererPointInfo(n, r, g, b); | 313 GenericRendererElementInfo* info = new GenericRendererPointInfo(n, r, g, b); |
314 m_groups[group].push_back(info); | 314 m_groups[group].push_back(info); |
315 } | 315 } |
316 void GenericRenderer::addQuad(int group, GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b) { | 316 void GenericRenderer::addQuad(const std::string &group, GenericRendererNode n1, GenericRendererNode n2, GenericRendererNode n3, GenericRendererNode n4, uint8_t r, uint8_t g, uint8_t b) { |
317 GenericRendererElementInfo* info = new GenericRendererQuadInfo(n1, n2, n3, n4, r, g, b); | 317 GenericRendererElementInfo* info = new GenericRendererQuadInfo(n1, n2, n3, n4, r, g, b); |
318 m_groups[group].push_back(info); | 318 m_groups[group].push_back(info); |
319 } | 319 } |
320 void GenericRenderer::addText(int group, GenericRendererNode n, AbstractFont* font, std::string text) { | 320 void GenericRenderer::addText(const std::string &group, GenericRendererNode n, AbstractFont* font, const std::string &text) { |
321 GenericRendererElementInfo* info = new GenericRendererTextInfo(n, font, text); | 321 GenericRendererElementInfo* info = new GenericRendererTextInfo(n, font, text); |
322 m_groups[group].push_back(info); | 322 m_groups[group].push_back(info); |
323 } | 323 } |
324 void GenericRenderer::addImage(int group, GenericRendererNode n, int image) { | 324 void GenericRenderer::addImage(const std::string &group, GenericRendererNode n, int image) { |
325 GenericRendererElementInfo* info = new GenericRendererImageInfo(n, image); | 325 GenericRendererElementInfo* info = new GenericRendererImageInfo(n, image); |
326 m_groups[group].push_back(info); | 326 m_groups[group].push_back(info); |
327 } | 327 } |
328 void GenericRenderer::addAnimation(int group, GenericRendererNode n, int animation) { | 328 void GenericRenderer::addAnimation(const std::string &group, GenericRendererNode n, int animation) { |
329 GenericRendererElementInfo* info = new GenericRendererAnimationInfo(n, animation); | 329 GenericRendererElementInfo* info = new GenericRendererAnimationInfo(n, animation); |
330 m_groups[group].push_back(info); | 330 m_groups[group].push_back(info); |
331 } | 331 } |
332 void GenericRenderer::removeAll(int group) { | 332 void GenericRenderer::removeAll(const std::string &group) { |
333 std::vector<GenericRendererElementInfo*>::const_iterator info_it = m_groups[group].begin(); | 333 std::vector<GenericRendererElementInfo*>::const_iterator info_it = m_groups[group].begin(); |
334 for (;info_it != m_groups[group].end(); ++info_it) { | 334 for (;info_it != m_groups[group].end(); ++info_it) { |
335 delete *info_it; | 335 delete *info_it; |
336 } | 336 } |
337 m_groups[group].clear(); | 337 m_groups[group].clear(); |
338 m_groups.erase(group); | 338 m_groups.erase(group); |
339 } | 339 } |
340 | 340 |
341 void GenericRenderer::render(Camera* cam, Layer* layer, std::vector<Instance*>& instances) { | 341 void GenericRenderer::render(Camera* cam, Layer* layer, std::vector<Instance*>& instances) { |
342 std::map<int, std::vector<GenericRendererElementInfo*> >::iterator group_it = m_groups.begin(); | 342 std::map<std::string, std::vector<GenericRendererElementInfo*> >::iterator group_it = m_groups.begin(); |
343 for(; group_it != m_groups.end(); ++group_it) { | 343 for(; group_it != m_groups.end(); ++group_it) { |
344 std::vector<GenericRendererElementInfo*>::const_iterator info_it = group_it->second.begin(); | 344 std::vector<GenericRendererElementInfo*>::const_iterator info_it = group_it->second.begin(); |
345 for (;info_it != group_it->second.end(); ++info_it) { | 345 for (;info_it != group_it->second.end(); ++info_it) { |
346 (*info_it)->render(cam, layer, instances, m_renderbackend, m_imagepool, m_animationpool); | 346 (*info_it)->render(cam, layer, instances, m_renderbackend, m_imagepool, m_animationpool); |
347 } | 347 } |