From ecf7a7e3e44b50f1b405805fc0af68a7178084b1 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 25 Mar 2010 14:14:46 +0000 Subject: [PATCH] From Stephan Huber, "attached you'll find a small enhancement for GraphicsWindowCocoa. My submision adds a getter for the pixel-format. I need this for some custom software so I can integrate CoreVideo-playback with osg. " --- include/osgViewer/api/Cocoa/GraphicsWindowCocoa | 4 ++++ src/osgViewer/GraphicsWindowCocoa.mm | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/osgViewer/api/Cocoa/GraphicsWindowCocoa b/include/osgViewer/api/Cocoa/GraphicsWindowCocoa index 965ce3a1b..dd8b18bf8 100755 --- a/include/osgViewer/api/Cocoa/GraphicsWindowCocoa +++ b/include/osgViewer/api/Cocoa/GraphicsWindowCocoa @@ -25,12 +25,14 @@ @class GraphicsWindowCocoaWindow; @class GraphicsWindowCocoaGLView; @class NSOpenGLContext; +@class NSOpenGLPixelFormat; @class NSWindow; @class NSView; #else class GraphicsWindowCocoaGLView; class GraphicsWindowCocoaWindow; class NSOpenGLContext; +class NSOpenGLPixelFormat; class NSWindow; class NSView; #endif @@ -158,6 +160,7 @@ class GraphicsWindowCocoa : public osgViewer::GraphicsWindow, public osgViewer:: NSOpenGLContext* getContext() { return _context; } GraphicsWindowCocoaWindow* getWindow() { return _window; } + NSOpenGLPixelFormat* getPixelFormat() { return _pixelformat; } void setVSync(bool f); @@ -190,6 +193,7 @@ class GraphicsWindowCocoa : public osgViewer::GraphicsWindow, public osgViewer:: GraphicsWindowCocoaWindow* _window; GraphicsWindowCocoaGLView* _view; NSOpenGLContext* _context; + NSOpenGLPixelFormat* _pixelformat; bool _updateContext; }; diff --git a/src/osgViewer/GraphicsWindowCocoa.mm b/src/osgViewer/GraphicsWindowCocoa.mm index 2c1666925..eb2b25899 100755 --- a/src/osgViewer/GraphicsWindowCocoa.mm +++ b/src/osgViewer/GraphicsWindowCocoa.mm @@ -857,6 +857,8 @@ void GraphicsWindowCocoa::init() _ownsWindow = false; _context = NULL; _window = NULL; + _pixelformat = NULL; + _updateContext = false; _valid = _initialized = true; } @@ -977,8 +979,8 @@ bool GraphicsWindowCocoa::realizeImplementation() sharedContext = graphicsHandleCocoa->getNSOpenGLContext(); } - NSOpenGLPixelFormat* pixelformat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr ]; - _context = [[NSOpenGLContext alloc] initWithFormat: pixelformat shareContext: sharedContext]; + _pixelformat = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr ]; + _context = [[NSOpenGLContext alloc] initWithFormat: _pixelformat shareContext: sharedContext]; if (!_context) { osg::notify(osg::WARN) << "GraphicsWindowCocoa::realizeImplementation :: could not create context" << std::endl;