From 3e8be9ac7dfa8edafd353761c5e4fe9716b4a99a Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 8 Jun 2007 11:04:30 +0000 Subject: [PATCH] From Stephan Huber, "attached you'll find a new GraphicsWindowCarbon-header and .cpp, the changes I made: + put a warning in the console if a nonexistant screen is requested + add getters for the aglcontext and pixelformat -- I need access to them in my own code. " --- include/osgViewer/api/Carbon/GraphicsWindowCarbon | 8 +++++++- src/osgViewer/GraphicsWindowCarbon.cpp | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) 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 */