From Craig Bosma,"Please find attached a fix for shared contexts on OS X, with the Cocoa backend. The NSOpenGLContext* _context member of GraphicsHandleCocoa was never set on successfully creation, so even if the dynamic_cast to GraphicsHandleCocoa succeeds, we get a bogus (NULL) pointer on retrieving the actual NSOpenGLContext* (line 1013).

This should fix the problem, as well as cause GraphicsWindowCocoa to report the correct name "GraphicsWindowCarbon" -> "GraphicsWindowCocoa".
"
This commit is contained in:
Robert Osfield 2011-04-26 12:05:57 +00:00
parent 0d97aab94f
commit d416ebc78c
2 changed files with 5 additions and 1 deletions

View File

@ -85,7 +85,7 @@ class GraphicsWindowCocoa : public osgViewer::GraphicsWindow, public osgViewer::
virtual bool isSameKindAs(const Object* object) const { return dynamic_cast<const GraphicsWindowCocoa*>(object)!=0; }
virtual const char* libraryName() const { return "osgViewer"; }
virtual const char* className() const { return "GraphicsWindowCarbon"; }
virtual const char* className() const { return "GraphicsWindowCocoa"; }
virtual bool valid() const { return _valid; }

View File

@ -1020,6 +1020,10 @@ bool GraphicsWindowCocoa::realizeImplementation()
OSG_WARN << "GraphicsWindowCocoa::realizeImplementation :: could not create context" << std::endl;
return false;
}
// set graphics handle for shared usage
setNSOpenGLContext(_context);
GraphicsWindowCocoaGLView* theView = [[ GraphicsWindowCocoaGLView alloc ] initWithFrame:[ _window frame ] ];
[theView setAutoresizingMask: (NSViewWidthSizable | NSViewHeightSizable) ];
[theView setGraphicsWindowCocoa: this];