xoreos  0.0.5
renderable.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include "src/common/system.h"
26 #include "src/common/error.h"
27 
29 #include "src/graphics/graphics.h"
30 
31 namespace Graphics {
32 
33 Renderable::Renderable(RenderableType type) : _clickable(false), _distance(0.0f) {
34  switch (type) {
38  break;
39 
43  break;
44 
48  break;
49 
53  break;
54 
58  break;
59 
60  default:
61  throw Common::Exception("Unknown Renderable type %d", type);
62  }
63 
65 
66  _id = GfxMan.createRenderableID();
67 }
68 
70  hide();
71 
73 }
74 
75 bool Renderable::operator<(const Queueable &q) const {
76  return _distance < static_cast<const Renderable &>(q)._distance;
77 }
78 
80 }
81 
82 double Renderable::getDistance() const {
83  return _distance;
84 }
85 
87  return _id;
88 }
89 
91  return _clickable;
92 }
93 
94 void Renderable::setClickable(bool clickable) {
95  _clickable = clickable;
96 }
97 
99  return _tag;
100 }
101 
103  _tag = tag;
104 }
105 
106 bool Renderable::isVisible() const {
107  return isInQueue(_queueVisible);
108 }
109 
112 }
113 
116 
119 
121 }
122 
125 }
126 
127 bool Renderable::isIn(float UNUSED(x), float UNUSED(y)) const {
128  return false;
129 }
130 
131 bool Renderable::isIn(float UNUSED(x), float UNUSED(y), float UNUSED(z)) const {
132  return false;
133 }
134 
135 bool Renderable::isIn(float UNUSED(x1), float UNUSED(y1), float UNUSED(z1),
136  float UNUSED(x2), float UNUSED(y2), float UNUSED(z2)) const {
137 
138  return false;
139 }
140 
142  GfxMan.lockFrame();
143 }
144 
146  GfxMan.unlockFrame();
147 }
148 
150  if (isVisible())
151  GfxMan.lockFrame();
152 }
153 
155  if (isVisible())
156  GfxMan.unlockFrame();
157 }
158 
159 } // End of namespace Graphics
const Common::UString & getTag() const
Get the object&#39;s tag.
Definition: renderable.cpp:98
virtual void show()
Show the object.
Definition: renderable.cpp:114
A GUI object, behind the world objects.
Definition: types.h:77
The global graphics manager.
virtual void hide()
Hide the object.
Definition: renderable.cpp:123
RenderableType
Definition: types.h:89
A class holding an UTF-8 string.
Definition: ustring.h:48
double _distance
The distance of the object from the viewer.
Definition: renderable.h:101
A visible Debug Console object, in front of the Front GUI.
Definition: types.h:81
A visible GUI object, in front of the world objects.
Definition: types.h:79
An object in 3D space.
Definition: types.h:74
void addToQueue(QueueType queue)
Definition: queueable.cpp:45
double getDistance() const
Get the distance of the object from the viewer.
Definition: renderable.cpp:82
A Debug Console object, in front of the Front GUI.
Definition: types.h:78
QueueType _queueVisible
Definition: renderable.h:94
A GUI object, in front of the world objects.
Definition: types.h:76
Common::UString _tag
Definition: renderable.h:99
Basic exceptions to throw.
void lockQueue(QueueType queue)
Definition: queueable.cpp:67
void setClickable(bool clickable)
Set the object&#39;s clickable state.
Definition: renderable.cpp:94
#define UNUSED(x)
Definition: system.h:170
virtual void advanceTime(float dt)
Advance time (used by renderables with animations).
Definition: renderable.cpp:79
void unlockQueue(QueueType queue)
Definition: queueable.cpp:71
A visible object in 3D space.
Definition: types.h:75
StackException Exception
Definition: error.h:59
QueueType _queueExists
Definition: renderable.h:93
A currently playing video.
Definition: types.h:83
virtual bool isIn(float x, float y) const
Is that point within the object?
Definition: renderable.cpp:127
void removeFromQueue(QueueType queue)
Definition: queueable.cpp:56
uint32 getID() const
Get the object&#39;s unique ID.
Definition: renderable.cpp:86
bool isVisible() const
Is the object visible?
Definition: renderable.cpp:106
uint32_t uint32
Definition: types.h:204
void sortQueue(QueueType queue)
Definition: queueable.cpp:75
Low-level detection of architecture/system properties.
bool operator<(const Queueable &q) const
Definition: renderable.cpp:75
void setTag(const Common::UString &tag)
Set the object&#39;s tag.
Definition: renderable.cpp:102
A video.
Definition: types.h:82
Renderable(RenderableType type)
Definition: renderable.cpp:33
bool isInQueue(QueueType queue) const
Definition: queueable.h:42
A visible GUI object, behind the world objects.
Definition: types.h:80
An object that can be displayed by the graphics manager.
#define GfxMan
Shortcut for accessing the graphics manager.
Definition: graphics.h:299
bool isClickable() const
Is the object clickable?
Definition: renderable.cpp:90