Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
wgldevice.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 #pragma once
20 #if !defined(__MITSUBA_HW_WGLDEVICE_H_)
21 #define __MITSUBA_HW_WGLDEVICE_H_
22 
23 #include <mitsuba/hw/device.h>
24 #include <mitsuba/hw/wglsession.h>
25 
27 
28 /** \brief Windows (WGL) device implementation
29  * \ingroup libhw
30  */
31 class MTS_EXPORT_HW WGLDevice : public Device {
32 public:
33  /// Create a new device
34  WGLDevice(WGLSession *session);
35 
36  /// Initialize the device
37  void init(Device *other = NULL);
38 
39  /// Shut the device down
40  void shutdown();
41 
42  /// Flip the buffers
43  virtual void flip();
44 
45  /// Only applies in windowed mode
46  void setVisible(bool enabled);
47 
48  /// Only applies in windowed mode
49  void setPosition(const Point2i &position);
50 
51  /// Set the window title
52  void setTitle(const std::string &title);
53 
54  /// Display the WGL cursor?
55  void showCursor(bool enabled);
56 
57  /// Move the mouse to another position
58  void warpMouse(const Point2i &position);
59 
60  /// Set the cursor grab state
61  void setGrab(bool grab);
62 
63  /// Associate a renderer with this device
64  void makeCurrent(Renderer *renderer);
65 
66  /// WNDPROC for event handling
67  static LONG WINAPI WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
68 
69  /// Return the device context
70  inline HDC getDeviceContext() const { return m_hdc; }
71 
73 protected:
74  /// Virtual destructor
75  virtual ~WGLDevice();
76 
77  /// Initialize the pixel format
78  void initPixelFormat(HWND hWnd);
79 
80  /// Translate a WIN32 key event
81  bool translateKey(WPARAM vkey, LPARAM lParam, DeviceEvent &event);
82 
83  /// Translate a WIN32 mouse event
84  bool translateMouse(UINT uMsg, WPARAM wParam, DeviceEvent &event);
85 protected:
86  ref<WGLDevice> m_parent;
87  HWND m_hwnd;
88  HDC m_hdc;
89  PIXELFORMATDESCRIPTOR m_pfd;
90  bool m_visible;
91  Point2i m_mouse;
92  int m_modifierState;
93  int m_buttonState;
94  int m_special[256];
95  char m_std[256];
96  bool m_leftShift;
97  bool m_rightShift;
98  bool m_grab;
99  bool m_cursor;
100  bool m_mouseInWindow;
101  int m_pf;
102 };
103 
105 
106 #endif /* __MITSUBA_HW_WGLDEVICE_H_ */
The device event structure encapsulates event information such as mouse movement or key presses...
Definition: device.h:34
Windows (WGL) device implementation.
Definition: wgldevice.h:31
HDC getDeviceContext() const
Return the device context.
Definition: wgldevice.h:70
virtual void setPosition(const Point2i &position)
Set the position of the device.
#define MTS_EXPORT_HW
Definition: platform.h:114
virtual void flip()
Flip the buffers (when using double buffering)
virtual void shutdown()
Shut the device down.
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)
Windows (WGL) windowing environment session.
Definition: wglsession.h:32
An abstract drawing device.
Definition: device.h:136
#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
Reference counting helper.
Definition: ref.h:40
Abstract renderer implementation.
Definition: renderer.h:79
virtual void setTitle(const std::string &title)
Set the window title.
#define MTS_NAMESPACE_END
Definition: platform.h:138