Changeset 10813
- Timestamp:
- 11/21/09 17:41:02 (4 years ago)
- Location:
- OpenSceneGraph/trunk
- Files:
-
- 3 added
- 14 modified
-
include/osgViewer/api/Carbon/GraphicsHandleCarbon (added)
-
include/osgViewer/api/Carbon/GraphicsWindowCarbon (modified) (3 diffs)
-
include/osgViewer/api/Carbon/PixelBufferCarbon (modified) (5 diffs)
-
include/osgViewer/api/Win32/GraphicsHandleWin32 (added)
-
include/osgViewer/api/Win32/GraphicsWindowWin32 (modified) (4 diffs)
-
include/osgViewer/api/Win32/PixelBufferWin32 (modified) (3 diffs)
-
include/osgViewer/api/X11/GraphicsHandleX11 (added)
-
include/osgViewer/api/X11/GraphicsWindowX11 (modified) (6 diffs)
-
include/osgViewer/api/X11/PixelBufferX11 (modified) (3 diffs)
-
src/osgViewer/CMakeLists.txt (modified) (4 diffs)
-
src/osgViewer/GraphicsWindowCarbon.cpp (modified) (1 diff)
-
src/osgViewer/GraphicsWindowWin32.cpp (modified) (4 diffs)
-
src/osgViewer/GraphicsWindowX11.cpp (modified) (5 diffs)
-
src/osgViewer/PixelBufferCarbon.cpp (modified) (1 diff)
-
src/osgViewer/PixelBufferWin32.cpp (modified) (3 diffs)
-
src/osgViewer/PixelBufferX11.cpp (modified) (2 diffs)
-
src/osgViewer/ScreenCaptureHandler.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osgViewer/api/Carbon/GraphicsWindowCarbon
r9904 r10813 23 23 24 24 #include <osgViewer/GraphicsWindow> 25 #include < Carbon/Carbon.h>26 #include <AGL/agl.h> 25 #include <osgViewer/api/Carbon/GraphicsHandleCarbon> 26 27 27 namespace osgViewer 28 28 { 29 29 30 class GraphicsWindowCarbon : public osgViewer::GraphicsWindow 30 class GraphicsWindowCarbon : public osgViewer::GraphicsWindow, public osgViewer::GraphicsHandleCarbon 31 31 { 32 32 public: … … 138 138 void installEventHandler(); 139 139 140 /// get the AGL context141 AGLContext getAGLContext() { return _context; }142 143 140 // get the pixelformat 144 141 AGLPixelFormat getAGLPixelFormat() { return _pixelFormat; } … … 160 157 bool _ownsWindow; 161 158 WindowRef _window; 162 AGLContext _context;163 159 AGLPixelFormat _pixelFormat; 164 160 -
OpenSceneGraph/trunk/include/osgViewer/api/Carbon/PixelBufferCarbon
r9904 r10813 20 20 21 21 #include <osg/GraphicsContext> 22 #include <osgViewer/Export> 23 24 #include <Carbon/Carbon.h> 25 #include <AGL/agl.h> 22 #include <osgViewer/api/Carbon/GraphicsHandleCarbon> 26 23 27 24 … … 29 26 { 30 27 31 class OSGVIEWER_EXPORT PixelBufferCarbon : public osg::GraphicsContext 28 class OSGVIEWER_EXPORT PixelBufferCarbon : public osg::GraphicsContext, public osgViewer::GraphicsHandleCarbon 32 29 { 33 30 public: … … 38 35 _realized(false), 39 36 _pixelformat(0), 40 _pbuffer(0), 41 _context(0) 37 _pbuffer(0) 42 38 { 43 39 _traits = traits; … … 92 88 /** Swap the front and back buffers.*/ 93 89 virtual void swapBuffersImplementation(); 94 90 95 91 static AGLPixelFormat createPixelFormat(osg::GraphicsContext::Traits* traits); 96 97 AGLContext getAGLContext() { return _context; }98 92 99 93 public: … … 113 107 114 108 AGLPixelFormat _pixelformat; 115 AGLPbuffer _pbuffer; 116 AGLContext _context; 117 109 AGLPbuffer _pbuffer; 118 110 }; 119 111 -
OpenSceneGraph/trunk/include/osgViewer/api/Win32/GraphicsWindowWin32
r10748 r10813 21 21 22 22 #include <osgViewer/GraphicsWindow> 23 24 #ifndef _WIN32_WINNT 25 #define _WIN32_WINNT 0x0500 26 #endif 27 #include <windows.h> 23 #include <osgViewer/api/Win32/GraphicsHandleWin32> 28 24 29 25 namespace osgViewer 30 26 { 31 27 32 class OSGVIEWER_EXPORT GraphicsWindowWin32 : public osgViewer::GraphicsWindow 28 class OSGVIEWER_EXPORT GraphicsWindowWin32 : public osgViewer::GraphicsWindow, public osgViewer::GraphicsHandleWin32 33 29 { 34 30 public: … … 104 100 bool _installEventHandler; 105 101 }; 106 107 /** Get native window.*/108 HWND getHWND() const { return _hwnd; }109 110 HDC getHDC() const { return _hdc; }111 112 /** Get native OpenGL graphics context.*/113 HGLRC getWGLContext() const { return _hglrc; }114 102 115 103 protected: … … 140 128 141 129 bool setPixelFormat(); 142 HGLRC createContextImplementation(); 143 130 144 131 void adaptKey( WPARAM wParam, LPARAM lParam, int& keySymbol, unsigned int& modifierMask ); 145 132 … … 150 137 HCURSOR getOrCreateCursor(MouseCursor mouseShape); 151 138 152 HWND _hwnd;153 HDC _hdc;154 HGLRC _hglrc;155 139 HCURSOR _currentCursor; 156 140 -
OpenSceneGraph/trunk/include/osgViewer/api/Win32/PixelBufferWin32
r7914 r10813 20 20 #define OSGVIEWER_PIXELBUFFERWIN32 1 21 21 22 #include <osgViewer/GraphicsWindow> 23 24 #ifndef _WIN32_WINNT 25 #define _WIN32_WINNT 0x0500 26 #endif 27 28 #include <windows.h> 22 #include <osg/GraphicsContext> 23 #include <osgViewer/api/Win32/GraphicsHandleWin32> 29 24 30 25 namespace osgViewer 31 26 { 32 27 33 class OSGVIEWER_EXPORT PixelBufferWin32 : public osg::GraphicsContext 28 class OSGVIEWER_EXPORT PixelBufferWin32 : public osg::GraphicsContext, public osgViewer::GraphicsHandleWin32 34 29 { 35 30 public: … … 63 58 /** Swap the front and back buffers.*/ 64 59 virtual void swapBuffersImplementation(); 65 66 /** Get native window.*/ 67 HWND getHWND() const { return _hwnd; } 68 69 HDC getHDC() const { return _hdc; } 70 71 /** Get native OpenGL graphics context.*/ 72 HGLRC getWGLContext() const { return _hglrc; } 73 60 74 61 virtual void bindPBufferToTextureImplementation( GLenum /*buffer*/ ); 75 62 … … 77 64 78 65 void init(); 79 80 HWND _hwnd;81 HDC _hdc;82 HGLRC _hglrc;83 66 84 67 bool _initialized; -
OpenSceneGraph/trunk/include/osgViewer/api/X11/GraphicsWindowX11
r10706 r10813 21 21 22 22 #include <osgViewer/GraphicsWindow> 23 24 #define GLX_GLXEXT_PROTOTYPES 1 25 26 #include <X11/X.h> 27 #include <X11/Xlib.h> 28 #include <X11/Xutil.h> 29 30 #if defined(OSG_GLES1_AVAILABLE) || defined(OSG_GLES2_AVAILABLE) 31 #define OSG_USE_EGL 32 #include <EGL/egl.h> 33 #else 34 #include <GL/glx.h> 35 #endif 36 23 #include <osgViewer/api/X11/GraphicsHandleX11> 37 24 38 25 #include <string.h> … … 41 28 { 42 29 43 class OSGVIEWER_EXPORT GraphicsWindowX11 : public osgViewer::GraphicsWindow 30 class OSGVIEWER_EXPORT GraphicsWindowX11 : public osgViewer::GraphicsWindow, public osgViewer::GraphicsHandleX11 44 31 { 45 32 public: … … 47 34 GraphicsWindowX11(osg::GraphicsContext::Traits* traits): 48 35 _valid(false), 49 _display(0),50 36 _eventDisplay(0), 51 37 _parent(0), 52 38 _window(0), 53 39 _visualInfo(0), 54 _context(0),55 40 #ifdef OSG_USE_EGL 56 41 _eglDisplay(0), … … 152 137 // X11 specific aces functions 153 138 154 Display* getDisplay() const { return _display; }155 139 Display* getEventDisplay() const { return _eventDisplay; } 156 140 Display* getDisplayToUse() const ; … … 159 143 Window& getParent() { return _parent; } 160 144 Window& getWindow() { return _window; } 161 162 163 #ifdef OSG_USE_EGL164 typedef EGLContext Context;165 #else166 typedef GLXContext Context;167 #endif168 169 Context& getContext() { return _context; }170 145 171 146 Cursor getCurrentCursor() { return _currentCursor; } … … 198 173 199 174 bool _valid; 200 Display* _display;201 175 Display* _eventDisplay; 202 176 Window _parent; 203 177 Window _window; 204 178 XVisualInfo* _visualInfo; 205 Context _context;206 179 207 180 #ifdef OSG_USE_EGL -
OpenSceneGraph/trunk/include/osgViewer/api/X11/PixelBufferX11
r10703 r10813 20 20 #define OSGVIEWER_PIXELBUFFERX11 1 21 21 22 #include <osgViewer/api/X11/GraphicsWindowX11> 23 24 #ifndef OSG_USE_EGL 25 #ifndef GLX_VERSION_1_3 26 typedef XID GLXPbuffer; 27 #endif 28 #endif 22 #include <osg/GraphicsContext> 23 #include <osgViewer/api/X11/GraphicsHandleX11> 29 24 30 25 namespace osgViewer 31 26 { 32 27 33 class OSGVIEWER_EXPORT PixelBufferX11 : public osg::GraphicsContext 28 class OSGVIEWER_EXPORT PixelBufferX11 : public osg::GraphicsContext, public osgViewer::GraphicsHandleX11 34 29 { 35 30 public: … … 70 65 71 66 // X11 specific aces functions 72 73 Display* getDisplay() const { return _display; }74 67 75 #ifdef OSG_USE_EGL76 typedef EGLContext Context;77 typedef EGLSurface Pbuffer;78 #else79 typedef GLXContext Context;80 typedef GLXPbuffer Pbuffer;81 #endif82 83 68 Pbuffer& getPbuffer() { return _pbuffer; } 84 Context& getContext() { return _context; }85 69 86 70 protected: … … 93 77 94 78 bool _valid; 95 Display* _display;96 79 Pbuffer _pbuffer; 97 80 XVisualInfo* _visualInfo; 98 Context _context;99 81 100 82 bool _initialized; -
OpenSceneGraph/trunk/src/osgViewer/CMakeLists.txt
r10703 r10813 54 54 55 55 SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS} 56 ${HEADER_PATH}/api/Win32/GraphicsHandleWin32 56 57 ${HEADER_PATH}/api/Win32/GraphicsWindowWin32 57 58 ${HEADER_PATH}/api/Win32/PixelBufferWin32 … … 85 86 ADD_DEFINITIONS(-DUSE_DARWIN_CARBON_IMPLEMENTATION) 86 87 SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS} 88 ${HEADER_PATH}/api/Carbon/GraphicsHandleCarbon 87 89 ${HEADER_PATH}/api/Carbon/GraphicsWindowCarbon 88 90 ${HEADER_PATH}/api/Carbon/PixelBufferCarbon … … 110 112 111 113 SET(LIB_PUBLIC_HEADERS ${LIB_PUBLIC_HEADERS} 114 ${HEADER_PATH}/api/X11/GraphicsHandleX11 112 115 ${HEADER_PATH}/api/X11/GraphicsWindowX11 113 116 ${HEADER_PATH}/api/X11/PixelBufferX11 … … 118 121 PixelBufferX11.cpp 119 122 ) 120 123 121 124 IF(OSGVIEWER_USE_XRANDR) 122 125 ADD_DEFINITIONS(-DOSGVIEWER_USE_XRANDR) -
OpenSceneGraph/trunk/src/osgViewer/GraphicsWindowCarbon.cpp
r9894 r10813 399 399 AGLContext sharedContextCarbon = NULL; 400 400 401 GraphicsWindowCarbon* graphicsWindowCarbon = dynamic_cast<GraphicsWindowCarbon*>(_traits->sharedContext); 402 if (graphicsWindowCarbon) 403 { 404 sharedContextCarbon = graphicsWindowCarbon->getAGLContext(); 405 } 406 else 407 { 408 PixelBufferCarbon* pixelbuffer = dynamic_cast<PixelBufferCarbon*>(_traits->sharedContext); 409 if (pixelbuffer) { 410 sharedContextCarbon = pixelbuffer->getAGLContext(); 411 } 412 } 401 GraphicsHandleCarbon* graphicsHandleCarbon = dynamic_cast<GraphicsHandleCarbon*>(_traits->sharedContext); 402 if (graphicsHandleCarbon) 403 { 404 sharedContextCarbon = graphicsHandleCarbon->getAGLContext(); 405 } 406 413 407 _context = aglCreateContext (_pixelFormat, sharedContextCarbon); 414 408 -
OpenSceneGraph/trunk/src/osgViewer/GraphicsWindowWin32.cpp
r10748 r10813 1030 1030 1031 1031 GraphicsWindowWin32::GraphicsWindowWin32( osg::GraphicsContext::Traits* traits ) 1032 : _hwnd(0), 1033 _hdc(0), 1034 _hglrc(0), 1035 _currentCursor(0), 1032 : _currentCursor(0), 1036 1033 _windowProcedure(0), 1037 1034 _timeOfLastCheckEvents(-1.0), … … 1784 1781 if (_traits.valid() && _traits->sharedContext) 1785 1782 { 1786 Graphics WindowWin32* sharedContextWin32 = dynamic_cast<GraphicsWindowWin32*>(_traits->sharedContext);1787 if ( sharedContextWin32)1783 GraphicsHandleWin32* graphicsHandleWin32 = dynamic_cast<GraphicsHandleWin32*>(_traits->sharedContext); 1784 if (graphicsHandleWin32) 1788 1785 { 1789 1786 struct RestoreContext … … 1805 1802 HGLRC _hglrc; 1806 1803 } restoreContext; 1807 1804 1808 1805 _realized = true; 1809 1806 bool result = makeCurrent(); … … 1814 1811 return false; 1815 1812 } 1816 if (!wglShareLists( sharedContextWin32->getWGLContext(), getWGLContext()))1813 if (!wglShareLists(graphicsHandleWin32->getWGLContext(), getWGLContext())) 1817 1814 { 1818 1815 reportErrorForScreen("GraphicsWindowWin32::realizeImplementation() - Unable to share OpenGL context", _traits->screenNum, ::GetLastError()); -
OpenSceneGraph/trunk/src/osgViewer/GraphicsWindowX11.cpp
r10803 r10813 694 694 } 695 695 696 Context sharedContextGLX = NULL; 697 698 // get any shared GLX contexts 699 GraphicsWindowX11* graphicsWindowX11 = dynamic_cast<GraphicsWindowX11*>(_traits->sharedContext); 700 if (graphicsWindowX11) 701 { 702 sharedContextGLX = graphicsWindowX11->getContext(); 703 } 704 else 705 { 706 PixelBufferX11* pixelBufferX11 = dynamic_cast<PixelBufferX11*>(_traits->sharedContext); 707 if (pixelBufferX11 && pixelBufferX11->valid()) 708 { 709 sharedContextGLX = pixelBufferX11->getContext(); 710 } 711 } 696 // get any shared GLX contexts 697 GraphicsHandleX11* graphicsHandleX11 = dynamic_cast<GraphicsHandleX11*>(_traits->sharedContext); 698 Context sharedContext = graphicsHandleX11 ? graphicsHandleX11->getContext() : 0; 712 699 713 700 #ifdef OSG_USE_EGL … … 775 762 #endif 776 763 777 _context = eglCreateContext(_eglDisplay, eglConfig, NULL, contextAttribs);764 _context = eglCreateContext(_eglDisplay, eglConfig, sharedContext, contextAttribs); 778 765 if (_context == EGL_NO_CONTEXT) 779 766 { … … 791 778 #else 792 779 793 _context = glXCreateContext( _display, _visualInfo, sharedContext GLX, True );780 _context = glXCreateContext( _display, _visualInfo, sharedContext, True ); 794 781 795 782 if (!_context) … … 990 977 bool result = eglMakeCurrent(_eglDisplay, _eglSurface, _eglSurface, _context)==EGL_TRUE; 991 978 checkEGLError("after eglMakeCurrent()"); 992 993 979 return result; 994 980 #else … … 1006 992 1007 993 #ifdef OSG_USE_EGL 1008 returneglMakeCurrent( _eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT )==EGL_TRUE;994 bool result = eglMakeCurrent( _eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT )==EGL_TRUE; 1009 995 checkEGLError("after eglMakeCurrent() release"); 996 return result; 1010 997 #else 1011 998 return glXMakeCurrent( _display, None, NULL )==True; -
OpenSceneGraph/trunk/src/osgViewer/PixelBufferCarbon.cpp
r10006 r10813 81 81 AGLContext sharedContext = NULL; 82 82 83 // get any shared GLXcontexts84 Graphics WindowCarbon* graphicsWindowCarbon = dynamic_cast<GraphicsWindowCarbon*>(_traits->sharedContext);85 if (graphics WindowCarbon)83 // get any shared AGL contexts 84 GraphicsHandleCarbon* graphicsHandleCarbon = dynamic_cast<GraphicsHandleCarbon*>(_traits->sharedContext); 85 if (graphicsHandleCarbon) 86 86 { 87 sharedContext = graphicsWindowCarbon->getAGLContext(); 88 } 89 else 90 { 91 PixelBufferCarbon* pixelBufferCarbon = dynamic_cast<PixelBufferCarbon*>(_traits->sharedContext); 92 if (pixelBufferCarbon) 93 { 94 sharedContext = pixelBufferCarbon->getAGLContext(); 95 } 87 sharedContext = graphicsHandleCarbon->getAGLContext(); 96 88 } 97 89 -
OpenSceneGraph/trunk/src/osgViewer/PixelBufferWin32.cpp
r9630 r10813 446 446 447 447 PixelBufferWin32::PixelBufferWin32( osg::GraphicsContext::Traits* traits ): 448 _hwnd(0),449 _hdc(0),450 _hglrc(0),451 448 _initialized(false), 452 449 _valid(false), … … 658 655 makeCurrentImplementation(); 659 656 660 if (_traits->sharedContext) 661 { 662 HGLRC hglrc = 0; 663 664 GraphicsWindowWin32* graphicsWindowWin32 = dynamic_cast<GraphicsWindowWin32*>(_traits->sharedContext); 665 if (graphicsWindowWin32) 666 { 667 hglrc = graphicsWindowWin32->getWGLContext(); 668 } 669 else 670 { 671 PixelBufferWin32* pixelBufferWin32 = dynamic_cast<PixelBufferWin32*>(_traits->sharedContext); 672 if (pixelBufferWin32) 657 if ( _traits->sharedContext ) 658 { 659 GraphicsHandleWin32* graphicsHandleWin32 = dynamic_cast<GraphicsHandleWin32*>(_traits->sharedContext); 660 if (graphicsHandleWin32) 661 { 662 if ( !wglShareLists(graphicsHandleWin32->getWGLContext(), _hglrc) ) 673 663 { 674 hglrc = pixelBufferWin32->getWGLContext();664 osg::notify(osg::NOTICE) << "PixelBufferWin32::realizeImplementation, wglShareLists error: " << sysError() << std::endl; 675 665 } 676 }677 678 if ( !wglShareLists(hglrc, _hglrc) )679 {680 osg::notify(osg::NOTICE) << "PixelBufferWin32::realizeImplementation, wglShareLists error: " << sysError() << std::endl;681 666 } 682 667 } … … 758 743 } 759 744 760 GraphicsWindowWin32* graphicsWindowWin32 = dynamic_cast<GraphicsWindowWin32*>(readContext); 761 if (graphicsWindowWin32) 762 { 763 return wgle->wglMakeContextCurrentARB(_hdc, graphicsWindowWin32->getHDC(), _hglrc); 764 } 765 PixelBufferWin32* pixelBufferWin32 = dynamic_cast<PixelBufferWin32*>(_traits->sharedContext); 766 if (pixelBufferWin32) 767 { 768 return wgle->wglMakeContextCurrentARB(_hdc, pixelBufferWin32->getHDC(), _hglrc); 745 GraphicsHandleWin32* graphicsHandleWin32 = dynamic_cast<GraphicsHandleWin32*>(readContext); 746 if (graphicsHandleWin32) 747 { 748 return wgle->wglMakeContextCurrentARB(_hdc, graphicsHandleWin32->getHDC(), _hglrc); 769 749 } 770 750 return false; -
OpenSceneGraph/trunk/src/osgViewer/PixelBufferX11.cpp
r10705 r10813 29 29 PixelBufferX11::PixelBufferX11(osg::GraphicsContext::Traits* traits) 30 30 : _valid(false), 31 _display(0),32 31 _pbuffer(0), 33 32 _visualInfo(0), 34 _context(0),35 33 _initialized(false), 36 34 _realized(false), … … 218 216 } 219 217 220 GLXContext sharedContextGLX = NULL; 221 222 // get any shared GLX contexts 223 GraphicsWindowX11* graphicsWindowX11 = dynamic_cast<GraphicsWindowX11*>(_traits->sharedContext); 224 if (graphicsWindowX11) 225 { 226 sharedContextGLX = graphicsWindowX11->getContext(); 227 } 228 else 229 { 230 PixelBufferX11* pixelBufferX11 = dynamic_cast<PixelBufferX11*>(_traits->sharedContext); 231 if (pixelBufferX11) 232 { 233 sharedContextGLX = pixelBufferX11->getContext(); 234 } 235 } 236 237 _context = glXCreateContext( _display, _visualInfo, sharedContextGLX, True ); 218 // get any shared GLX contexts 219 GraphicsHandleX11* graphicsHandleX11 = dynamic_cast<GraphicsHandleX11*>(_traits->sharedContext); 220 Context sharedContext = graphicsHandleX11 ? graphicsHandleX11->getContext() : 0; 221 222 _context = glXCreateContext( _display, _visualInfo, sharedContext, True ); 238 223 239 224 if (!_context) -
OpenSceneGraph/trunk/src/osgViewer/ScreenCaptureHandler.cpp
r10782 r10813 491 491 void WindowCaptureCallback::operator () (osg::RenderInfo& renderInfo) const 492 492 { 493 #if !defined(OSG_GLES1_AVAILABLE) && !defined(OSG_GLES2_AVAILABLE) 493 494 glReadBuffer(_readBuffer); 495 #endif 494 496 495 497 osg::GraphicsContext* gc = renderInfo.getState()->getGraphicsContext();
