Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
x11device.h
Go to the documentation of this file.
1 /*
2  This file is part of Mitsuba, a physically based rendering system.
3 
4  Copyright (c) 2007-2014 by Wenzel Jakob and others.
5 
6  Mitsuba is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License Version 3
8  as published by the Free Software Foundation.
9 
10  Mitsuba is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #if !defined(__MITSUBA_HW_X11DEVICE_H_)
20 #define __MITSUBA_HW_X11DEVICE_H_
21 
22 #include <mitsuba/hw/device.h>
23 #include <mitsuba/hw/x11session.h>
24 
26 
27 /** \brief X Window System (X11R6) device / software surface
28  * \ingroup libhw
29  */
30 class MTS_EXPORT_HW X11Device : public Device {
31  friend class X11Session;
32  friend class GLXRenderer;
33 public:
34  /// Create a new device
35  X11Device(X11Session *session);
36 
37  /// Initialize the device
38  void init(Device *other = NULL);
39 
40  /// Shut the device down
41  void shutdown();
42 
43  /// Flip the buffers
44  virtual void flip();
45 
46  /// Only applies in windowed mode
47  void setVisible(bool enabled);
48 
49  /// Only applies in windowed mode
50  void setPosition(const Point2i &position);
51 
52  /// Set the window title
53  void setTitle(const std::string &title);
54 
55  /// Display the X11 cursor?
56  void showCursor(bool enabled);
57 
58  /// Set the cursor grab state
59  void setGrab(bool grab);
60 
61  /// Move the mouse to another position
62  void warpMouse(const Point2i &position);
63 
64  /// Handle an X11 event. Called by the session
65  void processEvent(const XEvent &event);
66 
67  /// Associate a renderer with this device
68  void makeCurrent(Renderer *renderer);
69 
71 protected:
72  /// Virtual destructor
73  virtual ~X11Device();
74 
75  /// Create a visual
76  virtual XVisualInfo* createVisual();
77 private:
78  /// Translate X11 mouse events
79  void translateMouse(const XEvent &xEvent, DeviceEvent &event);
80 
81  /// Translate X11 keyboard events
82  bool translateKeyboard(const XEvent &xEvent, DeviceEvent &event);
83 
84  /// Return the X11 window
85  inline Window getWindow() { return m_window; }
86 
87  /// Return the X11 visual
88  inline XVisualInfo *getVisual() { return m_visinfo; }
89 protected:
90  Window m_window;
91  XVisualInfo *m_visinfo;
92  XF86VidModeModeInfo m_previousMode;
94  bool m_visible;
95  Cursor m_cursor;
96  int m_keymap[256];
100  bool m_grab;
101 };
102 
104 
105 #endif /* __MITSUBA_HW_X11DEVICE_H_ */
The device event structure encapsulates event information such as mouse movement or key presses...
Definition: device.h:34
int m_buttonState
Definition: x11device.h:99
virtual void setPosition(const Point2i &position)
Set the position of the device.
#define MTS_EXPORT_HW
Definition: platform.h:114
GLX (XFree86) renderer.
Definition: glxrenderer.h:30
virtual void flip()
Flip the buffers (when using double buffering)
X Window System (X11R6) session.
Definition: x11session.h:31
virtual void shutdown()
Shut the device down.
int m_modifierState
Definition: x11device.h:98
X Window System (X11R6) device / software surface.
Definition: x11device.h:30
virtual void makeCurrent(Renderer *renderer)=0
Associate the renderer with this device.
virtual void setVisible(bool visible)=0
Only applies to devices, which are UI windows.
#define MTS_NAMESPACE_BEGIN
Definition: platform.h:137
virtual void init(Device *other=NULL)
Atom m_deleteWindow
Definition: x11device.h:93
An abstract drawing device.
Definition: device.h:136
Window m_window
Definition: x11device.h:90
#define MTS_DECLARE_CLASS()
This macro must be used in the initial definition in classes that derive from Object.
Definition: class.h:158
Definition: fwd.h:99
Point2i m_mouse
Definition: x11device.h:97
Cursor m_cursor
Definition: x11device.h:95
Abstract renderer implementation.
Definition: renderer.h:79
bool m_grab
Definition: x11device.h:100
virtual void setTitle(const std::string &title)
Set the window title.
bool m_visible
Definition: x11device.h:94
XF86VidModeModeInfo m_previousMode
Definition: x11device.h:92
#define MTS_NAMESPACE_END
Definition: platform.h:138
XVisualInfo * m_visinfo
Definition: x11device.h:91