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:
Robert Osfield
2011-04-19 12:01:38 +00:00
parent efec8a13a1
commit c13b7d26b7
9 changed files with 133 additions and 31 deletions

View File

@@ -30,6 +30,9 @@ extern "C"
namespace osgViewer {
class View;
/** Base class for providing Windowing API agnostic access to creating and managing graphics window and events.
* Note, the GraphicsWindow is subclassed from osg::GraphicsContext, and to provide an implemention you'll need to implement its
* range of pure virtual functions, you'll find these all have naming convention methodNameImplemention(..).
@@ -180,8 +183,13 @@ class OSGVIEWER_EXPORT GraphicsWindow : public osg::GraphicsContext, public osgG
public:
typedef std::list<osgViewer::View*> Views;
/** Returns the list of views (osgViewer::View) attached to this GraphicsWindow.
* Internally, the method walks through all the cameras and collects all the views attached to the cameras.*/
void getViews(Views& views);
// Override from GUIActionAdapter
virtual void requestRedraw() {}
virtual void requestRedraw();
// Override from GUIActionAdapter
virtual void requestContinuousUpdate(bool /*needed*/=true) {}

View File

@@ -195,9 +195,6 @@ class OSGVIEWER_EXPORT ViewerBase : public virtual osg::Object
osgUtil::IncrementalCompileOperation* getIncrementalCompileOperation() { return _incrementalCompileOperation.get(); }
/** Check to see if windows are still open, if not set viewer done to true. */
void checkWindowStatus();
enum FrameScheme
{
ON_DEMAND,
@@ -253,6 +250,15 @@ class OSGVIEWER_EXPORT ViewerBase : public virtual osg::Object
typedef std::vector<osgViewer::View*> Views;
virtual void getViews(Views& views, bool onlyValid=true) = 0;
/** Check to see if any windows are still open. If not, set viewer done to true. */
void checkWindowStatus();
/** Check to see if windows are still open using the list of contexts given as a parameter.
* If no windows are open, stop rendering threads and set viewer done to true.
* This function is more effective than checkWindowStatus() as it does not query
* the context list and should be used whenever context list is already available in your code.*/
void checkWindowStatus(const Contexts& contexts);
virtual double elapsedTime() = 0;
virtual osg::FrameStamp* getViewerFrameStamp() = 0;