Equalizer  1.6.1
include/eq/client/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/client/glWindow.h> // base class
23 #include <eq/client/gl.h> // for HPBUFFERARB from wglew.h
24 #include <eq/client/wgl/types.h>
25 
26 namespace eq
27 {
28 namespace wgl
29 {
31  class WindowIF : public GLWindow
32  {
33  public:
35  WindowIF( eq::Window* parent ) : GLWindow( parent ) {}
36 
38  virtual ~WindowIF() {}
39 
41  EQ_API virtual HGLRC getWGLContext() const = 0;
42 
44  EQ_API virtual HWND getWGLWindowHandle() const = 0;
45 
47  EQ_API virtual HPBUFFERARB getWGLPBufferHandle() const = 0;
48 
53  EQ_API virtual HDC getWGLDC() const = 0;
54 
56  virtual HDC getWGLAffinityDC() { return 0; }
57 
59  EQ_API virtual bool processEvent( const WindowEvent& event ) = 0;
60 
61  private:
62  struct Private;
63  Private* _private; // placeholder for binary-compatible changes
64  };
65 
67  class Window : public WindowIF
68  {
69  public:
71  EQ_API Window( eq::Window* parent );
72 
74  EQ_API virtual ~Window( );
75 
87  EQ_API virtual void setWGLContext( HGLRC context );
88 
90 
99  EQ_API virtual void setWGLWindowHandle( HWND handle );
100 
110  EQ_API virtual void setWGLPBufferHandle( HPBUFFERARB handle );
111 
113  virtual HWND getWGLWindowHandle() const { return _wglWindow; }
114 
116  virtual HPBUFFERARB getWGLPBufferHandle() const { return _wglPBuffer; }
117 
122  virtual HDC getWGLDC() const { return _wglDC; }
123 
125  virtual HGLRC getWGLContext() const { return _wglContext; }
126 
129  { return _wglEventHandler; }
131 
145  EQ_API virtual bool configInit();
146 
148  EQ_API virtual void configExit( );
149 
156  EQ_API virtual bool initWGLAffinityDC();
157 
159  EQ_API virtual void exitWGLAffinityDC();
160 
162  EQ_API virtual HDC getWGLAffinityDC();
163 
173  EQ_API virtual HDC createWGLDisplayDC();
174 
184  EQ_API virtual int chooseWGLPixelFormat();
185 
196  EQ_API virtual bool configInitWGLDrawable( int pixelFormat );
197 
207  EQ_API virtual bool configInitWGLWindow( int pixelFormat );
208 
218  EQ_API virtual bool configInitWGLPBuffer( int pixelFormat );
219 
221  EQ_API virtual bool configInitWGLFBO( int pixelFormat );
222 
231  EQ_API virtual HGLRC createWGLContext();
232 
234  EQ_API virtual void destroyWGLContext( HGLRC context );
235 
240  EQ_API virtual void initEventHandler();
241 
246  EQ_API virtual void exitEventHandler();
248 
252  EQ_API virtual void makeCurrent( const bool cache = true ) const;
253 
255  EQ_API virtual void swapBuffers();
256 
258  EQ_API virtual void joinNVSwapBarrier( const uint32_t group,
259  const uint32_t barrier );
260 
261 
263  void leaveNVSwapBarrier();
264 
266  EQ_API virtual bool processEvent( const WindowEvent& event );
268 
269  protected:
272  {
278  };
279 
286  void setWGLDC( HDC dc, const WGLDCType type );
287 
289  EQ_API WGLEWContext* wglewGetContext();
290 
292  Pipe* getWGLPipe();
293 
294  private:
295 
296  HWND _wglWindow;
297  HPBUFFERARB _wglPBuffer;
298  HGLRC _wglContext;
299 
300  HDC _wglDC;
301  WGLDCType _wglDCType;
302  HDC _wglAffinityDC;
303 
304  EventHandler* _wglEventHandler;
305  BOOL _screenSaverActive;
306 
307  uint32_t _wglNVSwapGroup;
308 
309  struct Private;
310  Private* _private; // placeholder for binary-compatible changes
311 
313  HWND _createWGLWindow( const PixelViewport& pvp );
314 
316  int _chooseWGLPixelFormatARB( HDC pfDC );
317 
319  int _chooseWGLPixelFormat( HDC pfDC );
320 
321  void _initSwapSync();
322  };
323 }
324 }
325 #endif // EQ_WGL_WINDOW_H
326 
virtual HDC createWGLDisplayDC()
Create a device context for the display device of the window.
virtual ~WindowIF()
Destruct the WGL window.
virtual ~Window()
Destruct the WGL window.
The WGL DC belongs to a PBuffer.
virtual HPBUFFERARB getWGLPBufferHandle() const =0
virtual void exitWGLAffinityDC()
Destroy the affinity device context.
virtual HDC getWGLAffinityDC()
The event handler for WGL.
Equalizer default implementation of a WGL window.
virtual void configExit()
A Window represents an on-screen or off-screen drawable.
void leaveNVSwapBarrier()
Unbind a WGL_NV_swap_barrier.
virtual bool configInit()
Initialize this window for the WGL window system.
virtual bool configInitWGLDrawable(int pixelFormat)
Initialize the window&#39;s drawable (pbuffer or window) and bind the WGL context.
A system window for OpenGL rendering.
Definition: glWindow.h:33
const EventHandler * getWGLEventHandler() const
virtual void setWGLContext(HGLRC context)
Set the WGL rendering context for this window.
virtual HPBUFFERARB getWGLPBufferHandle() const
virtual HDC getWGLDC() const =0
virtual bool configInitWGLPBuffer(int pixelFormat)
Initialize the window with an off-screen WGL PBuffer.
WGLDCType
The type of the Win32 device context.
virtual bool configInitWGLFBO(int pixelFormat)
Initialize the window for an off-screen FBO.
A window-system event for a WindowIF.
virtual int chooseWGLPixelFormat()
Choose a pixel format based on the window&#39;s attributes.
virtual HGLRC getWGLContext() const
virtual HWND getWGLWindowHandle() const =0
virtual void joinNVSwapBarrier(const uint32_t group, const uint32_t barrier)
Join the WGL_NV_swap_group.
WGLEWContext * wglewGetContext()
virtual bool processEvent(const WindowEvent &event)
virtual bool processEvent(const WindowEvent &event)=0
Process the given event.
virtual bool configInitWGLWindow(int pixelFormat)
Initialize the window with an on-screen Win32 window.
virtual HGLRC getWGLContext() const =0
Pipe * getWGLPipe()
Window(eq::Window *parent)
Create a new WGL window for the given eq::Window.
virtual HGLRC createWGLContext()
Create a WGL context.
virtual void initEventHandler()
Set up an WGLEventHandler, called by setWGLWindowHandle().
virtual bool initWGLAffinityDC()
Create, if needed, an affinity device context for this window.
virtual HDC getWGLDC() const
virtual void setWGLWindowHandle(HWND handle)
Set the Win32 window handle for this window.
virtual void swapBuffers()
virtual void makeCurrent(const bool cache=true) const
Equalizer default implementation of a WGL GPU.
virtual void setWGLPBufferHandle(HPBUFFERARB handle)
Set the Win32 off screen pbuffer handle for this window.
The WGL DC belongs to a window.
virtual void destroyWGLContext(HGLRC context)
Destroy the given WGL context.
Includes OpenGL and GLEW headers.
The interface defining the minimum functionality for a WGL window.
virtual HWND getWGLWindowHandle() const
virtual void exitEventHandler()
Destroy the WGLEventHandler, called by setWGLWindowHandle().
WindowIF(eq::Window *parent)
Construct a new WGL window for the given eq::Window.
void setWGLDC(HDC dc, const WGLDCType type)
Set new device context and release the old DC.