diff --git a/examples/osgviewerCocoa/ViewerCocoa.mm b/examples/osgviewerCocoa/ViewerCocoa.mm index 959bbcee6..5376cb1fa 100644 --- a/examples/osgviewerCocoa/ViewerCocoa.mm +++ b/examples/osgviewerCocoa/ViewerCocoa.mm @@ -297,6 +297,10 @@ static void Internal_SetAlpha(NSBitmapImageRep *imageRep, unsigned char alpha_va osg::DisplaySettings::instance()->setMaxNumberOfGraphicsContexts(1); #endif // VIEWER_USE_SHARED_CONTEXTS + // set the draw and read buffers up for a double buffered window with rendering going to back buffer + theViewer->getCamera()->setDrawBuffer(GL_BACK); + theViewer->getCamera()->setReadBuffer(GL_BACK); + // Cocoa follows the same coordinate convention as OpenGL. osgViewer's default is inverted. theViewer->getEventQueue()->getCurrentEventState()->setMouseYOrientation(osgGA::GUIEventAdapter::Y_INCREASING_UPWARDS); // Use a trackball manipulator...matches nicely with the Mighty Mouse Scrollball. diff --git a/examples/osgviewerFLTK/osgviewerFLTK.cpp b/examples/osgviewerFLTK/osgviewerFLTK.cpp index e43e9d539..8cfd143d6 100644 --- a/examples/osgviewerFLTK/osgviewerFLTK.cpp +++ b/examples/osgviewerFLTK/osgviewerFLTK.cpp @@ -104,6 +104,11 @@ class ViewerFLTK : public osgViewer::Viewer, public AdapterWidget getCamera()->setViewport(new osg::Viewport(0,0,w,h)); getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast(w)/static_cast(h), 1.0f, 10000.0f); getCamera()->setGraphicsContext(getGraphicsWindow()); + + // set the draw and read buffers up for a double buffered window with rendering going to back buffer + getCamera()->setDrawBuffer(GL_BACK); + getCamera()->setReadBuffer(GL_BACK); + setThreadingModel(osgViewer::Viewer::SingleThreaded); } @@ -161,6 +166,11 @@ int main( int argc, char **argv ) view1->getCamera()->setGraphicsContext(viewerWindow.getGraphicsWindow()); view1->getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast(width)/static_cast(height/2), 1.0, 1000.0); view1->getCamera()->setViewport(new osg::Viewport(0,0,width,height/2)); + + // set the draw and read buffers up for a double buffered window with rendering going to back buffer + view1->getCamera()->setDrawBuffer(GL_BACK); + view1->getCamera()->setReadBuffer(GL_BACK); + view1->setCameraManipulator(new osgGA::TrackballManipulator); view1->setSceneData(loadedModel.get()); @@ -172,6 +182,11 @@ int main( int argc, char **argv ) view2->getCamera()->setGraphicsContext(viewerWindow.getGraphicsWindow()); view2->getCamera()->setProjectionMatrixAsPerspective(30.0f, static_cast(width)/static_cast(height/2), 1.0, 1000.0); view2->getCamera()->setViewport(new osg::Viewport(0,height/2,width,height/2)); + + // set the draw and read buffers up for a double buffered window with rendering going to back buffer + view2->getCamera()->setDrawBuffer(GL_BACK); + view2->getCamera()->setReadBuffer(GL_BACK); + view2->setCameraManipulator(new osgGA::TrackballManipulator); view2->setSceneData(loadedModel.get()); diff --git a/examples/osgviewerFOX/FOX_OSG_MDIView.cpp b/examples/osgviewerFOX/FOX_OSG_MDIView.cpp index df6124e2e..ae4cd9d56 100644 --- a/examples/osgviewerFOX/FOX_OSG_MDIView.cpp +++ b/examples/osgviewerFOX/FOX_OSG_MDIView.cpp @@ -32,6 +32,11 @@ FOX_OSG_MDIView::FOX_OSG_MDIView(FXMDIClient *p, const FXString &name, osgViewer::Viewer *viewer = new osgViewer::Viewer; viewer->getCamera()->setGraphicsContext(m_gwFox); viewer->getCamera()->setViewport(0,0,w,h); + + // set the draw and read buffers up for a double buffered window with rendering going to back buffer + viewer->getCamera()->setDrawBuffer(GL_BACK); + viewer->getCamera()->setReadBuffer(GL_BACK); + viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded); // FOX example does not catch the close of the graphics window, so diff --git a/examples/osgviewerIPhone/iphoneViewerAppDelegate.mm b/examples/osgviewerIPhone/iphoneViewerAppDelegate.mm index 439fe60ee..9df3f79a7 100644 --- a/examples/osgviewerIPhone/iphoneViewerAppDelegate.mm +++ b/examples/osgviewerIPhone/iphoneViewerAppDelegate.mm @@ -301,6 +301,10 @@ private: { _viewer->getCamera()->setGraphicsContext(graphicsContext); _viewer->getCamera()->setViewport(new osg::Viewport(0, 0, traits->width, traits->height)); + + // set the draw and read buffers up for a double buffered window with rendering going to back buffer + _viewer->getCamera()->setDrawBuffer(GL_BACK); + _viewer->getCamera()->setReadBuffer(GL_BACK); } } diff --git a/examples/osgviewerMFC/MFC_OSG.cpp b/examples/osgviewerMFC/MFC_OSG.cpp index 6baf62d2a..6f891dd1d 100644 --- a/examples/osgviewerMFC/MFC_OSG.cpp +++ b/examples/osgviewerMFC/MFC_OSG.cpp @@ -112,6 +112,10 @@ void cOSG::InitCameraConfig(void) camera->setProjectionMatrixAsPerspective( 30.0f, static_cast(traits->width)/static_cast(traits->height), 1.0, 1000.0); + // set the draw and read buffers up for a double buffered window with rendering going to back buffer + camera->setDrawBuffer(GL_BACK); + camera->setReadBuffer(GL_BACK); + // Add the Camera to the Viewer //mViewer->addSlave(camera.get()); mViewer->setCamera(camera.get()); diff --git a/examples/osgviewerQt/osgviewerQt.cpp b/examples/osgviewerQt/osgviewerQt.cpp index defb79c8a..3f4246cb4 100644 --- a/examples/osgviewerQt/osgviewerQt.cpp +++ b/examples/osgviewerQt/osgviewerQt.cpp @@ -53,6 +53,11 @@ public: camera->setClearColor( osg::Vec4(0.2, 0.2, 0.6, 1.0) ); camera->setViewport( new osg::Viewport(0, 0, traits->width, traits->height) ); + + // set the draw and read buffers up for a double buffered window with rendering going to back buffer + camera->setDrawBuffer(GL_BACK); + camera->setReadBuffer(GL_BACK); + camera->setProjectionMatrixAsPerspective(30.0f, static_cast(traits->width)/static_cast(traits->height), 1.0f, 10000.0f ); view->setSceneData( scene ); diff --git a/examples/osgviewerSDL/osgviewerSDL.cpp b/examples/osgviewerSDL/osgviewerSDL.cpp index 6c6b8bbac..cd1ee885f 100644 --- a/examples/osgviewerSDL/osgviewerSDL.cpp +++ b/examples/osgviewerSDL/osgviewerSDL.cpp @@ -128,6 +128,11 @@ int main( int argc, char **argv ) osgViewer::Viewer viewer; osg::ref_ptr gw = viewer.setUpViewerAsEmbeddedInWindow(0,0,windowWidth,windowHeight); + + // set the draw and read buffers up for a double buffered window with rendering going to back buffer + viewer.getCamera()->setDrawBuffer(GL_BACK); + viewer.getCamera()->setReadBuffer(GL_BACK); + viewer.setSceneData(loadedModel.get()); viewer.setCameraManipulator(new osgGA::TrackballManipulator); viewer.addEventHandler(new osgViewer::StatsHandler); diff --git a/examples/osgviewerWX/osgviewerWX.cpp b/examples/osgviewerWX/osgviewerWX.cpp index c4a198a4d..d30f3272b 100644 --- a/examples/osgviewerWX/osgviewerWX.cpp +++ b/examples/osgviewerWX/osgviewerWX.cpp @@ -64,6 +64,11 @@ bool wxOsgApp::OnInit() osgViewer::Viewer *viewer = new osgViewer::Viewer; viewer->getCamera()->setGraphicsContext(gw); viewer->getCamera()->setViewport(0,0,width,height); + + // set the draw and read buffers up for a double buffered window with rendering going to back buffer + viewer->getCamera()->setDrawBuffer(GL_BACK); + viewer->getCamera()->setReadBuffer(GL_BACK); + viewer->addEventHandler(new osgViewer::StatsHandler); viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);