Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk: the crosshair now renders as element2d

File size: 2.2 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::tick(float dt)
80{
81  tIterator<Element2D>* iterator = this->element2DList->getIterator();
82  Element2D* elem = iterator->nextElement();
83  while (elem != NULL)
84  {
85    elem->tick(dt);
86    elem = iterator->nextElement();
87  }
88  delete iterator;
89
90}
91
92/**
93 * renders all the Elements of the Render2D-engine
94 */
95void Render2D::draw() const
96{
97  GraphicsEngine::enter2DMode();
98
99  tIterator<Element2D>* iterator = this->element2DList->getIterator();
100  Element2D* elem = iterator->nextElement();
101  while (elem != NULL)
102  {
103    if (elem->isVisible())
104      elem->draw();
105    elem = iterator->nextElement();
106  }
107  delete iterator;
108
109  GraphicsEngine::leave2DMode();
110}
Note: See TracBrowser for help on using the repository browser.