20 #if !defined(__MITSUBA_HW_DEVICE_H_)
21 #define __MITSUBA_HW_DEVICE_H_
43 inline unsigned short getType()
const {
return m_type; }
46 inline void setType(
int type) { m_type = type; }
61 inline void setMouseButton(
unsigned short button) { m_mouse.button = button; }
97 std::string toString()
const;
99 unsigned short m_type;
104 char key, interpreted[16];
127 virtual bool deviceEventOccurred(
const DeviceEvent &event) = 0;
142 EKeyDownEvent = 0x0002,
143 EKeyUpEvent = 0x0004,
144 EMouseMotionEvent = 0x0008,
145 EMouseDragEvent = 0x0010,
146 EMouseButtonDownEvent = 0x0020,
147 EMouseButtonUpEvent = 0x0040,
148 EMouseEnterEvent = 0x0080,
149 EMouseLeaveEvent = 0x0100,
150 EMouseBeginDragEvent = 0x0200,
151 EMouseEndDragEvent = 0x0400,
152 EMouseDoubleClickEvent = 0x0800,
153 EGainFocusEvent = 0x1000,
154 ELoseFocusEvent = 0x2000,
155 EResizeEvent = 0x4000
160 EShiftModifier = 0x01,
161 EControlModifier = 0x02,
170 EMiddleButton = 0x02,
172 EWheelUpButton = 0x08,
173 EWheelDownButton = 0x10
248 void setSize(
const Vector2i &dimension);
257 virtual void setPosition(
const Point2i &position);
260 void setFSAA(
int fsaa);
266 virtual void setVisible(
bool visible) = 0;
273 void setColorBits(
int colorBits);
276 void setRedBits(
int redBits);
282 void setGreenBits(
int greenBits);
288 void setBlueBits(
int blueBits);
294 void setAlphaBits(
int alphaBits);
300 void setDepthBits(
int depthBits);
306 void setStencilBits(
int stencilBits);
312 void setDoubleBuffer(
bool doubleBuffer);
318 void setFullscreen(
bool fullscreen);
324 void setResizeAllowed(
bool resizeAllowed);
330 void setCenter(
bool center);
336 inline void setShowFPS(
bool showFPS) { m_showFPS = showFPS; }
342 inline int getFPS()
const {
return m_fps; }
345 void setXPos(
int xpos);
348 virtual void setTitle(
const std::string &title);
351 inline const std::string &
getTitle()
const {
return m_title; }
365 virtual void init(
Device *other = NULL);
368 virtual void shutdown();
377 virtual void makeCurrent(
Renderer *renderer) = 0;
400 int m_redBits, m_greenBits, m_blueBits;
401 int m_alphaBits, m_depthBits, m_stencilBits;
402 bool m_doubleBuffer, m_initialized, m_fullscreen;
403 bool m_center, m_showFPS, m_resizeAllowed;
404 int m_fpsCounter, m_fps, m_lastTime;
int getAlphaBits() const
Return the amount of bits for the alpha component.
Definition: device.h:297
TVector2< int > Vector2i
Definition: fwd.h:108
void setKeyboardSpecial(unsigned short special)
Set the pressed keyboard key special identifier enum (see Device::ESpecialKeys)
Definition: device.h:73
The device event structure encapsulates event information such as mouse movement or key presses...
Definition: device.h:34
EMouseButton
Device keyboard event modifiers.
Definition: device.h:167
virtual ~DeviceEventListener()
Virtual destructor.
Definition: device.h:130
const char * getKeyboardInterpreted() const
Get the interpreted keypress data.
Definition: device.h:85
bool getDoubleBuffer() const
Definition: device.h:315
void setMouseRelative(const Vector2i &relative)
Get the relative mouse movement vector.
Definition: device.h:55
char key
Definition: device.h:104
unsigned short getKeyboardModifiers() const
Get the keyboard modifiers (see Device::EKeyboardModifiers)
Definition: device.h:82
DeviceEvent(unsigned short type)
Type constructor.
Definition: device.h:40
Point2i getPosition() const
Return the position of the device.
Definition: device.h:254
const std::string & getTitle() const
Return the window title.
Definition: device.h:351
bool getCenter() const
Return whether window centering is enabled.
Definition: device.h:333
DeviceEvent()
Default constructor.
Definition: device.h:37
EKeyboardModifiers
Device keyboard event modifiers.
Definition: device.h:159
unsigned short getKeyboardSpecial() const
Get the pressed keyboard key special identifier enum (see Device::ESpecialKeys)
Definition: device.h:76
Vector2i getMouseRelative() const
Set the relative mouse movement vector.
Definition: device.h:58
char getKeyboardKey() const
Get the pressed keyboard key (latin1)
Definition: device.h:70
void setType(int type)
Set the event type.
Definition: device.h:46
unsigned short getMouseButton() const
Get the enum of the pressed mouse button.
Definition: device.h:64
void setKeyboardModifiers(unsigned short modifiers)
Set the keyboard modifiers (see Device::EKeyboardModifiers)
Definition: device.h:79
bool getShowFPS() const
Return whether to show the frames per second.
Definition: device.h:339
EEventType
Device event types.
Definition: device.h:139
int getRedBits() const
Return the amount of bits for the red component.
Definition: device.h:279
Vector2i getSize() const
Return the dimension of the device.
Definition: device.h:245
int yrel
Definition: device.h:108
unsigned short button
Definition: device.h:109
ESpecialKeys
Device special keys.
Definition: device.h:177
An abstract drawing device.
Definition: device.h:136
unsigned short special
Definition: device.h:103
void setMousePosition(const Point2i &position)
Get the mouse position vector.
Definition: device.h:49
Abstract device event callback.
Definition: device.h:121
Float getAspect() const
Return the aspect ratio of the device.
Definition: device.h:251
Session * getSession()
Get the session.
Definition: device.h:357
#define MTS_DECLARE_CLASS()
This macro must be used in the initial definition in classes that derive from Object.
Definition: class.h:158
Reference counting helper.
Definition: ref.h:40
Abstract renderer implementation.
Definition: renderer.h:79
int getFSAA() const
Return the FSAA sample count.
Definition: device.h:263
Platform independent milli/micro/nanosecond timerThis class implements a simple cross-platform timer ...
Definition: timer.h:37
int getStencilBits() const
Return the amount of bits for the stencil component.
Definition: device.h:309
Abstract windowing environment session.
Definition: session.h:32
Point2i getMousePosition() const
Set the mouse position vector.
Definition: device.h:52
int getDepthBits() const
Return the amount of bits for the depth component.
Definition: device.h:303
const Session * getSession() const
Get the session.
Definition: device.h:354
unsigned short getType() const
Return the event type.
Definition: device.h:43
void setMouseButton(unsigned short button)
Set the enum of the pressed mouse button.
Definition: device.h:61
void setKeyboardKey(char key)
Set the pressed keyboard key (latin1)
Definition: device.h:67
bool isResizeAllowed() const
Return whether it is possible to resize the window.
Definition: device.h:327
void setShowFPS(bool showFPS)
Define whether to show the frames per second.
Definition: device.h:336
Object * getActionSource()
Get the event source.
Definition: device.h:94
Parent of all Mitsuba classes.
Definition: object.h:38
Object * source
Definition: device.h:113
TPoint2< int > Point2i
Definition: fwd.h:131
void setActionSource(Object *source)
Set the event source.
Definition: device.h:91
int getFPS() const
Return the frames per second (0 if no data is available)
Definition: device.h:342
char * getKeyboardInterpreted()
Get the interpreted keypress data.
Definition: device.h:88
bool getFullscreen() const
Return whether full screen drawing is enabled.
Definition: device.h:321
int getGreenBits() const
Return the amount of bits for the green component.
Definition: device.h:285
int getBlueBits() const
Return the amount of bits for the blue component.
Definition: device.h:291