From 526ba8c5063dbe274236823cdd015ed0531fdea4 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 16 Feb 2007 13:33:29 +0000 Subject: [PATCH] From Stephan Huber, "I added a bool to GraphicsContext::Traits to indicate wether to use the multithreaded-opengl-engine on os x or not. I set its default to false, perhaps other os x users can test this setting with their data/apps, to see if we can enable it by default. I changed also the borderless-window-type, so expos?works correctly." --- include/osg/GraphicsContext | 4 ++++ src/osgViewer/GraphicsWindowCarbon.cpp | 16 ++++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/include/osg/GraphicsContext b/include/osg/GraphicsContext index a14d7df82..feb58e314 100644 --- a/include/osg/GraphicsContext +++ b/include/osg/GraphicsContext @@ -75,6 +75,7 @@ class OSG_EXPORT GraphicsContext : public Object face(0), mipMapGeneration(false), vsync(true), + useMultiThreadedOpenGLEngine(false), useCursor(true), sharedContext(0) {} @@ -115,6 +116,9 @@ class OSG_EXPORT GraphicsContext : public Object // V-sync bool vsync; + // use multithreaded OpenGL-engine (OS X only) + bool useMultiThreadedOpenGLEngine; + // enable cursor bool useCursor; diff --git a/src/osgViewer/GraphicsWindowCarbon.cpp b/src/osgViewer/GraphicsWindowCarbon.cpp index 88501eebf..e16e80035 100644 --- a/src/osgViewer/GraphicsWindowCarbon.cpp +++ b/src/osgViewer/GraphicsWindowCarbon.cpp @@ -581,15 +581,16 @@ bool GraphicsWindowCarbon::realizeImplementation() attr = (kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute); else attr = (kWindowStandardDocumentAttributes | kWindowStandardHandlerAttribute) & ~kWindowResizableAttribute; - err = CreateNewWindow(kDocumentWindowClass, attr, &bounds, &_window); } - else { - attr = kWindowStandardHandlerAttribute; + else + { + attr = kWindowNoTitleBarAttribute | kWindowNoShadowAttribute | kWindowStandardHandlerAttribute; if (_traits->supportsResize) attr |= kWindowResizableAttribute; - err = CreateNewWindow(kSimpleWindowClass, attr, &bounds, &_window); } - + + err = CreateNewWindow(kDocumentWindowClass, attr, &bounds, &_window); + if (err) { osg::notify(osg::WARN) << "GraphicsWindowCarbon::realizeImplementation() failed creating a window: " << err << std::endl; return false; @@ -641,8 +642,7 @@ bool GraphicsWindowCarbon::realizeImplementation() makeCurrent(); - // disabling Multi-threaded OpenGL Execution because it slows down rendering, perhaps we should add a new attribute to traits? - /* + if ((_traits->useMultiThreadedOpenGLEngine) && (OpenThreads::GetNumberOfProcessors() > 1)) { // enable Multi-threaded OpenGL Execution: CGLError cgerr = kCGLNoError; CGLContextObj ctx = CGLGetCurrentContext(); @@ -653,7 +653,7 @@ bool GraphicsWindowCarbon::realizeImplementation() { osg::notify(osg::INFO) << "GraphicsWindowCarbon:: Multi-threaded OpenGL Execution not available" << std::endl; } - */ + } aglSetDrawable(_context, GetWindowPort(_window)); ShowWindow(_window);