Equalizer
1.4.1
|
00001 00002 /* Copyright (c) 2005-2012, Stefan Eilemann <eile@equalizergraphics.com> 00003 * 2009, Maxim Makhinya 00004 * 00005 * This library is free software; you can redistribute it and/or modify it under 00006 * the terms of the GNU Lesser General Public License version 2.1 as published 00007 * by the Free Software Foundation. 00008 * 00009 * This library is distributed in the hope that it will be useful, but WITHOUT 00010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00011 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00012 * details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public License 00015 * along with this library; if not, write to the Free Software Foundation, Inc., 00016 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00017 */ 00018 00019 #ifndef EQ_WGL_WINDOW_H 00020 #define EQ_WGL_WINDOW_H 00021 00022 #include <eq/client/glWindow.h> // base class 00023 #include <eq/client/gl.h> // for HPBUFFERARB from wglew.h 00024 #include <eq/client/wgl/types.h> 00025 00026 namespace eq 00027 { 00028 namespace wgl 00029 { 00031 class WindowIF : public GLWindow 00032 { 00033 public: 00035 WindowIF( eq::Window* parent ) : GLWindow( parent ) {} 00036 00038 virtual ~WindowIF() {} 00039 00041 EQ_API virtual HGLRC getWGLContext() const = 0; 00042 00044 EQ_API virtual HWND getWGLWindowHandle() const = 0; 00045 00047 EQ_API virtual HPBUFFERARB getWGLPBufferHandle() const = 0; 00048 00053 EQ_API virtual HDC getWGLDC() const = 0; 00054 00056 virtual HDC getWGLAffinityDC() { return 0; } 00057 00059 EQ_API virtual bool processEvent( const WindowEvent& event ) = 0; 00060 00061 private: 00062 struct Private; 00063 Private* _private; // placeholder for binary-compatible changes 00064 }; 00065 00067 class Window : public WindowIF 00068 { 00069 public: 00071 EQ_API Window( eq::Window* parent ); 00072 00074 EQ_API virtual ~Window( ); 00075 00087 EQ_API virtual void setWGLContext( HGLRC context ); 00088 00090 00099 EQ_API virtual void setWGLWindowHandle( HWND handle ); 00100 00110 EQ_API virtual void setWGLPBufferHandle( HPBUFFERARB handle ); 00111 00113 virtual HWND getWGLWindowHandle() const { return _wglWindow; } 00114 00116 virtual HPBUFFERARB getWGLPBufferHandle() const { return _wglPBuffer; } 00117 00122 virtual HDC getWGLDC() const { return _wglDC; } 00123 00125 virtual HGLRC getWGLContext() const { return _wglContext; } 00126 00128 const EventHandler* getWGLEventHandler() const 00129 { return _wglEventHandler; } 00131 00145 EQ_API virtual bool configInit(); 00146 00148 EQ_API virtual void configExit( ); 00149 00156 EQ_API virtual bool initWGLAffinityDC(); 00157 00159 EQ_API virtual void exitWGLAffinityDC(); 00160 00162 EQ_API virtual HDC getWGLAffinityDC(); 00163 00173 EQ_API virtual HDC createWGLDisplayDC(); 00174 00184 EQ_API virtual int chooseWGLPixelFormat(); 00185 00196 EQ_API virtual bool configInitWGLDrawable( int pixelFormat ); 00197 00207 EQ_API virtual bool configInitWGLWindow( int pixelFormat ); 00208 00218 EQ_API virtual bool configInitWGLPBuffer( int pixelFormat ); 00219 00221 EQ_API virtual bool configInitWGLFBO( int pixelFormat ); 00222 00231 EQ_API virtual HGLRC createWGLContext(); 00232 00234 EQ_API virtual void destroyWGLContext( HGLRC context ); 00235 00240 EQ_API virtual void initEventHandler(); 00241 00246 EQ_API virtual void exitEventHandler(); 00248 00252 EQ_API virtual void makeCurrent( const bool cache = true ) const; 00253 00255 EQ_API virtual void swapBuffers(); 00256 00258 EQ_API virtual void joinNVSwapBarrier( const uint32_t group, 00259 const uint32_t barrier ); 00260 00261 00263 void leaveNVSwapBarrier(); 00264 00266 EQ_API virtual bool processEvent( const WindowEvent& event ); 00268 00269 protected: 00271 enum WGLDCType 00272 { 00273 WGL_DC_NONE, 00274 WGL_DC_WINDOW, 00275 WGL_DC_PBUFFER, 00276 WGL_DC_AFFINITY, 00277 WGL_DC_DISPLAY 00278 }; 00279 00286 void setWGLDC( HDC dc, const WGLDCType type ); 00287 00289 EQ_API WGLEWContext* wglewGetContext(); 00290 00292 Pipe* getWGLPipe(); 00293 00294 private: 00295 00296 HWND _wglWindow; 00297 HPBUFFERARB _wglPBuffer; 00298 HGLRC _wglContext; 00299 00300 HDC _wglDC; 00301 WGLDCType _wglDCType; 00302 HDC _wglAffinityDC; 00303 00304 EventHandler* _wglEventHandler; 00305 BOOL _screenSaverActive; 00306 00307 uint32_t _wglNVSwapGroup; 00308 00309 struct Private; 00310 Private* _private; // placeholder for binary-compatible changes 00311 00313 HWND _createWGLWindow( int pixelFormat, const PixelViewport& pvp ); 00314 00316 int _chooseWGLPixelFormatARB( HDC pfDC ); 00317 00319 int _chooseWGLPixelFormat( HDC pfDC ); 00320 00321 void _initSwapSync(); 00322 }; 00323 } 00324 } 00325 #endif // EQ_WGL_WINDOW_H 00326