From 98cdeac9f677610c5185c98ab748526b796eaf9b Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 6 Mar 2018 16:54:57 +0000 Subject: [PATCH] Added missing Camera::setDrawBuffer/setReadBuffer() --- examples/osgviewerCocoa/ViewerCocoa.mm | 4 ++++ examples/osgviewerFOX/FOX_OSG_MDIView.cpp | 5 +++++ examples/osgviewerIPhone/iphoneViewerAppDelegate.mm | 2 ++ examples/osgviewerMFC/MFC_OSG.cpp | 4 ++++ examples/osgviewerSDL/osgviewerSDL.cpp | 5 +++++ examples/osgviewerWX/osgviewerWX.cpp | 7 +++++-- 6 files changed, 25 insertions(+), 2 deletions(-) diff --git a/examples/osgviewerCocoa/ViewerCocoa.mm b/examples/osgviewerCocoa/ViewerCocoa.mm index ea24ba825..3c7770d12 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/osgviewerFOX/FOX_OSG_MDIView.cpp b/examples/osgviewerFOX/FOX_OSG_MDIView.cpp index 9dccc0791..dfc1733ec 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 fc328b2c3..06b27d7f3 100644 --- a/examples/osgviewerIPhone/iphoneViewerAppDelegate.mm +++ b/examples/osgviewerIPhone/iphoneViewerAppDelegate.mm @@ -318,6 +318,8 @@ private: _viewer->getCamera()->setGraphicsContext(graphicsContext); _viewer->getCamera()->setViewport(new osg::Viewport(0, 0, traits->width, traits->height)); _viewer->getCamera()->setProjectionMatrixAsPerspective(60.0, (double)traits->width/(double)traits->height, 0.1, 1000.0); + _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..d27acdf65 100644 --- a/examples/osgviewerMFC/MFC_OSG.cpp +++ b/examples/osgviewerMFC/MFC_OSG.cpp @@ -106,6 +106,10 @@ void cOSG::InitCameraConfig(void) // Set the viewport for the Camera camera->setViewport(new osg::Viewport(traits->x, traits->y, 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); + // Set projection matrix and camera attribtues camera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); camera->setClearColor(osg::Vec4f(0.2f, 0.2f, 0.4f, 1.0f)); 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 bccd5cd23..9550d7cd3 100644 --- a/examples/osgviewerWX/osgviewerWX.cpp +++ b/examples/osgviewerWX/osgviewerWX.cpp @@ -64,8 +64,11 @@ bool wxOsgApp::OnInit() osgViewer::Viewer *viewer = new osgViewer::Viewer; viewer->getCamera()->setGraphicsContext(gw); viewer->getCamera()->setViewport(0,0,width,height); - viewer->getCamera()->setDrawBuffer(GL_BACK); - viewer->getCamera()->setReadBuffer(GL_BACK); + + // 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);