From Jan Peciva, "please find attached proposed fix for ON_DEMAND rendering. The biggest issue was
that the windows did not act on repaint request (WM_PAINT, EXPOSE,...) Detailed explanation: - I implemented requestRedraw using the push approach (not using GraphicsWindow::_requestRedraw flag that I was considering) as there may be multiple viewers reading the flag and fighting to reset it after the paint request, while some viewers may not spot the request to redraw - I made windows call GraphicsWindow::requestRedraw when they receive appropriate message (WM_PAINT, EXPOSE, RESIZE,...) - There were issues on Linux that windows did not want to close using x button. Resolved by moving the test for DeleteWindow event from swapBuffersImplementation() to GraphicsWindowX11::checkEvents(). The difficulty was that DeleteWindow event is not coming using _eventDisplay, but through _display. - The last difficulty was that it is necessary to call ViewerBase::checkWindowStatus() to set _done to true when all windows are closed. This did not happened recently in ON_DEMAND run scheme. I put the call to checkWindowStatus() to eventTraversal. "
This commit is contained in:
60
src/osgViewer/GraphicsWindow.cpp
Normal file
60
src/osgViewer/GraphicsWindow.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2011 Robert Osfield
|
||||
*
|
||||
* This library is open source and may be redistributed and/or modified under
|
||||
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
||||
* (at your option) any later version. The full license is in LICENSE file
|
||||
* included with this distribution, and on the openscenegraph.org website.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* OpenSceneGraph Public License for more details.
|
||||
*/
|
||||
|
||||
#include <osgViewer/GraphicsWindow>
|
||||
#include <osgViewer/View>
|
||||
#include <osgViewer/ViewerBase>
|
||||
|
||||
using namespace osgViewer;
|
||||
|
||||
|
||||
void GraphicsWindow::getViews(Views& views)
|
||||
{
|
||||
views.clear();
|
||||
osgViewer::View *prev = NULL;
|
||||
|
||||
for(Cameras::iterator it = _cameras.begin();
|
||||
it != _cameras.end();
|
||||
it++)
|
||||
{
|
||||
osgViewer::View *v = dynamic_cast<osgViewer::View*>((*it)->getView());
|
||||
if (v)
|
||||
// perform a simple test to reduce the number of duplicates
|
||||
if (v != prev)
|
||||
// append view
|
||||
views.push_back(v);
|
||||
}
|
||||
|
||||
// remove duplicates
|
||||
views.sort();
|
||||
views.unique();
|
||||
}
|
||||
|
||||
void GraphicsWindow::requestRedraw()
|
||||
{
|
||||
Views views;
|
||||
getViews(views);
|
||||
|
||||
if (views.empty())
|
||||
{
|
||||
OSG_INFO << "GraphicsWindow::requestRedraw(): No views assigned yet." << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
for(Views::iterator it = views.begin();
|
||||
it != views.end();
|
||||
it++)
|
||||
{
|
||||
(*it)->requestRedraw();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user