Equalizer  2.0.0
Parallel Rendering Framework
wgl/window.h
1 
2 /* Copyright (c) 2005-2012, Stefan Eilemann <eile@equalizergraphics.com>
3  * 2009, Maxim Makhinya
4  *
5  * This library is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU Lesser General Public License version 2.1 as published
7  * by the Free Software Foundation.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef EQ_WGL_WINDOW_H
20 #define EQ_WGL_WINDOW_H
21 
22 #include <eq/glWindow.h> // base class
23 #include <eq/gl.h> // for HPBUFFERARB from wglew.h
24 #include <eq/wgl/types.h>
25 
26 namespace eq
27 {
28 namespace wgl
29 {
30 namespace detail { class Window; }
31 
33 class WindowIF : public GLWindow
34 {
35 public:
37  WindowIF( NotifierInterface& parent, const WindowSettings& settings )
38  : GLWindow( parent, settings ) {}
39 
41  virtual ~WindowIF() {}
42 
44  EQ_API virtual HGLRC getWGLContext() const = 0;
45 
47  EQ_API virtual HWND getWGLWindowHandle() const = 0;
48 
50  EQ_API virtual HPBUFFERARB getWGLPBufferHandle() const = 0;
51 
56  EQ_API virtual HDC getWGLDC() const = 0;
57 
59  virtual HDC getWGLAffinityDC() { return 0; }
60 
62  virtual bool processEvent( EventType type, SizeEvent& event )
63  { return GLWindow::processEvent( type, event ); }
64 
66  virtual bool processEvent( EventType type, PointerEvent& event )
67  { return GLWindow::processEvent( type, event ); }
68 
70  virtual bool processEvent( EventType type, KeyEvent& event )
71  { return GLWindow::processEvent( type, event ); }
72 
74  virtual bool processEvent( EventType type, AxisEvent& event )
75  { return GLWindow::processEvent( type, event ); }
76 
78  virtual bool processEvent( EventType type, ButtonEvent& event )
79  { return GLWindow::processEvent( type, event ); }
80 
82  virtual bool processEvent( EventType ) { return false; }
83 };
84 
86 class Window : public WindowIF
87 {
88 public:
90  EQ_API Window( NotifierInterface& parent, const WindowSettings& settings,
91  Pipe& pipe );
92 
94  EQ_API virtual ~Window( );
95 
107  EQ_API virtual void setWGLContext( HGLRC context );
108 
110 
119  EQ_API virtual void setWGLWindowHandle( HWND handle );
120 
130  EQ_API virtual void setWGLPBufferHandle( HPBUFFERARB handle );
131 
133  EQ_API virtual HWND getWGLWindowHandle() const;
134 
136  EQ_API virtual HPBUFFERARB getWGLPBufferHandle() const;
137 
142  EQ_API virtual HDC getWGLDC() const;
143 
145  EQ_API virtual HGLRC getWGLContext() const;
146 
148  EQ_API const EventHandler* getWGLEventHandler() const;
150 
164  EQ_API virtual bool configInit();
165 
167  EQ_API virtual void configExit( );
168 
175  EQ_API virtual bool initWGLAffinityDC();
176 
178  EQ_API virtual void exitWGLAffinityDC();
179 
181  EQ_API virtual HDC getWGLAffinityDC();
182 
192  EQ_API virtual HDC createWGLDisplayDC();
193 
203  EQ_API virtual int chooseWGLPixelFormat();
204 
215  EQ_API virtual bool configInitWGLDrawable( int pixelFormat );
216 
226  EQ_API virtual bool configInitWGLWindow( int pixelFormat );
227 
237  EQ_API virtual bool configInitWGLPBuffer( int pixelFormat );
238 
240  EQ_API virtual bool configInitWGLFBO( int pixelFormat );
241 
250  EQ_API virtual HGLRC createWGLContext();
251 
253  EQ_API virtual void destroyWGLContext( HGLRC context );
254 
259  EQ_API virtual void initEventHandler();
260 
265  EQ_API virtual void exitEventHandler();
267 
271  EQ_API virtual void makeCurrent( const bool cache = true ) const;
272 
274  EQ_API virtual void doneCurrent() const;
275 
277  EQ_API virtual void swapBuffers();
278 
280  EQ_API virtual void joinNVSwapBarrier( const uint32_t group,
281  const uint32_t barrier );
282 
283 
285  void leaveNVSwapBarrier();
286 
287  EQ_API bool processEvent( EventType type, PointerEvent& event ) override;
288  EQ_API bool processEvent( EventType type ) override;
290 
291 protected:
293  EQ_API WGLEWContext* wglewGetContext();
294 
295 private:
296  detail::Window* const _impl;
297 
299  HWND _createWGLWindow( const PixelViewport& pvp );
300 
302  int _chooseWGLPixelFormatARB( HDC pfDC );
303 
305  int _chooseWGLPixelFormat( HDC pfDC );
306 
307  void _initSwapSync();
308 };
309 }
310 }
311 #endif // EQ_WGL_WINDOW_H
312 
The interface defining the minimum functionality for a WGL window.
Definition: wgl/window.h:33
Equalizer default implementation of a WGL window.
Definition: wgl/window.h:86
virtual ~WindowIF()
Destruct the WGL window.
Definition: wgl/window.h:41
A set of settings to setup an eq::SystemWindow.
virtual bool processEvent(EventType type, PointerEvent &event)
Process a mouse event.
Definition: wgl/window.h:66
Equalizer default implementation of a WGL GPU.
Definition: wgl/pipe.h:32
virtual bool processEvent(EventType type, ButtonEvent &event)
Process a button event.
Definition: wgl/window.h:78
The event handler for WGL.
virtual bool processEvent(EventType type, AxisEvent &event)
Process an axis event.
Definition: wgl/window.h:74
virtual bool processEvent(EventType)
Process a stateless event.
Definition: wgl/window.h:82
WindowIF(NotifierInterface &parent, const WindowSettings &settings)
Construct a new WGL window for the given eq::Window.
Definition: wgl/window.h:37
A system window for OpenGL rendering.
Definition: glWindow.h:36
A base class for notifying errors and events.
EQ_API bool processEvent(EventType type)
Process a stateless event.
The Equalizer client library.
Definition: eq/agl/types.h:23
virtual HDC getWGLAffinityDC()
Definition: wgl/window.h:59
virtual bool processEvent(EventType type, SizeEvent &event)
Process a (re)size event.
Definition: wgl/window.h:62
virtual bool processEvent(EventType type, KeyEvent &event)
Process a keyboard event.
Definition: wgl/window.h:70
Includes OpenGL and GLEW headers.