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: Benjamin Grauer |
---|
13 | co-programmer: ... |
---|
14 | */ |
---|
15 | |
---|
16 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS |
---|
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 | |
---|
25 | #include <math.h> |
---|
26 | |
---|
27 | using namespace std; |
---|
28 | |
---|
29 | /** |
---|
30 | * standard constructor |
---|
31 | */ |
---|
32 | Render2D::Render2D () |
---|
33 | { |
---|
34 | this->setClassID(CL_RENDER_2D, "Render2D"); |
---|
35 | this->setName("Render2D"); |
---|
36 | } |
---|
37 | |
---|
38 | /** |
---|
39 | * the singleton reference to this class |
---|
40 | */ |
---|
41 | Render2D* Render2D::singletonRef = NULL; |
---|
42 | |
---|
43 | /** |
---|
44 | * standard deconstructor |
---|
45 | */ |
---|
46 | Render2D::~Render2D () |
---|
47 | { |
---|
48 | delete NullElement2D::getInstance(); |
---|
49 | |
---|
50 | Render2D::singletonRef = NULL; |
---|
51 | } |
---|
52 | |
---|
53 | /** |
---|
54 | * updates all the 2d-elements |
---|
55 | * @param dt the timestep since last dt |
---|
56 | */ |
---|
57 | void Render2D::update(float dt) |
---|
58 | { |
---|
59 | NullElement2D::getInstance()->update2D(dt); |
---|
60 | } |
---|
61 | |
---|
62 | |
---|
63 | /** |
---|
64 | * ticks all the 2d-elements |
---|
65 | * @param dt the timestep since last dt |
---|
66 | */ |
---|
67 | void Render2D::tick(float dt) |
---|
68 | { |
---|
69 | NullElement2D::getInstance()->tick2D(dt); |
---|
70 | } |
---|
71 | |
---|
72 | /** |
---|
73 | * renders all the Elements of the Render2D-engine's layer |
---|
74 | * @param layer the Layer to draw (if E2D_LAYER_ALL then all layers will be drawn) |
---|
75 | */ |
---|
76 | void Render2D::draw(short layer) const |
---|
77 | { |
---|
78 | GraphicsEngine::enter2DMode(); |
---|
79 | NullElement2D::getInstance()->draw2D(E2D_LAYER_ALL); |
---|
80 | GraphicsEngine::leave2DMode(); |
---|
81 | } |
---|
82 | |
---|
83 | |
---|