Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/lib/graphics/render2D/render_2d.cc @ 4848

Last change on this file since 4848 was 4848, checked in by bensch, 19 years ago

orxonox/trunk: more 2D-definitions, better draw function

File size: 1.9 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: ...
13   co-programmer: ...
14*/
15
16//#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
17
18#include "render_2d.h"
19
20#include "graphics_engine.h"
21#include "class_list.h"
22#include "list.h"
23#include "element_2d.h"
24
25using namespace std;
26
27
28
29/**
30 * standard constructor
31 */
32Render2D::Render2D ()
33{
34   this->setClassID(CL_RENDER_2D, "Render2D");
35   this->setName("Render2D");
36
37   this->element2DList = new tList<Element2D>;
38}
39
40/**
41 *  the singleton reference to this class
42 */
43Render2D* Render2D::singletonRef = NULL;
44
45/**
46 * standard deconstructor
47 */
48Render2D::~Render2D ()
49{
50  delete this->element2DList;
51
52  Render2D::singletonRef = NULL;
53}
54
55
56/**
57 * registers a 2D-element to the 2D-Renderer
58 * @param element2D the element to registers
59 *
60 * do not use this function by yourself, because this is used by Element2D's constructor
61 */
62void Render2D::registerElement2D(Element2D* element2D)
63{
64  this->element2DList->add(element2D);
65}
66
67/**
68 * unregisters a 2D-element from the 2D-Renderer
69 * @param element2D The element to unregister
70 *
71 * do not use this function by yourself, because this is used by Element2D's destructor
72 */
73void Render2D::unregisterElement2D(Element2D* element2D)
74{
75  this->element2DList->remove(element2D);
76}
77
78
79void Render2D::draw() const
80{
81  GraphicsEngine::enter2DMode();
82
83  tIterator<Element2D>* iterator = this->element2DList->getIterator();
84  Element2D* elem = iterator->nextElement();
85  while (elem != NULL)
86  {
87    if (elem->isVisible())
88      elem->draw();
89    elem = iterator->nextElement();
90  }
91  delete iterator;
92
93  GraphicsEngine::leave2DMode();
94}
Note: See TracBrowser for help on using the repository browser.