diff --git a/include/osgViewer/api/Carbon/GraphicsWindowCarbon b/include/osgViewer/api/Carbon/GraphicsWindowCarbon index 8b2c97ed3..092647ea7 100644 --- a/include/osgViewer/api/Carbon/GraphicsWindowCarbon +++ b/include/osgViewer/api/Carbon/GraphicsWindowCarbon @@ -121,6 +121,12 @@ class GraphicsWindowCarbon : public osgViewer::GraphicsWindow /// install the standard os-eventhandler void installEventHandler(); + + /// get the AGL context + AGLContext getAGLContext() { return _context; } + + // get the pixelformat + AGLPixelFormat getAGLPixelFormat() { return _pixelFormat; } protected: @@ -128,7 +134,7 @@ class GraphicsWindowCarbon : public osgViewer::GraphicsWindow void transformMouseXY(float& x, float& y); - AGLContext& getAGLContext() { return _context; } + diff --git a/src/osgViewer/GraphicsWindowCarbon.cpp b/src/osgViewer/GraphicsWindowCarbon.cpp index e44a7c9ef..c7891d5fd 100644 --- a/src/osgViewer/GraphicsWindowCarbon.cpp +++ b/src/osgViewer/GraphicsWindowCarbon.cpp @@ -475,7 +475,12 @@ struct OSXCarbonWindowingSystemInterface : public osg::GraphicsContext::Windowin /** @return a CGDirectDisplayID for a ScreenIdentifier */ inline CGDirectDisplayID getDisplayID(const osg::GraphicsContext::ScreenIdentifier& si) { - return _displayIds[si.screenNum]; + if (si.screenNum < _displayCount) + return _displayIds[si.screenNum]; + else { + osg::notify(osg::WARN) << "GraphicsWindowCarbon :: invalid screen # " << si.screenNum << ", returning main-screen instead" << std::endl; + return _displayIds[0]; + } } /** @return count of attached screens */