I did some more research into what's going on and, on a hunch, changed my
threading model from ThreadPerCamera (default for my PC) to SingleThreaded and
ThreadPerContext. I found that setAbortRenderPtr does indeed lock up the camera
thread on ThreadPerCamera, however it seems to behave 100% correctly (in not
rendering anything when enabled) under the SingleThreaded and ThreadPerContext
models.
An easy way to reproduce it would be to add a keyboard input event handler that
calls setAbortRenderPtr on the viewer state. With ThreadPerCamera, the scene
should lock up. With the other models, it should just stop rendering though
still remain responsive.
From: osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf
Of Ben Strukus
Sent: Monday, January 19, 2015 4:08 PM
To: OpenSceneGraph Users
Subject: [osg-users] Aborting frames that take too long
Hi,
I'm having a problem trying to use OSG for a specific scenario. My simulation
contains several screens all showing the same scene at different angles (think
projector setup). I'd like to synchronize the frames among them so that tearing
between screens is minimal. Due to the nature of my scenes, some screens will
have more to render than others and, as a result, take longer to render (ground
vs sky). I'm looking for a way to interrupt a render loop and restart it if I
detect it's taking too long for my liking.
I've looked at a few proposed solutions by others with a similar problem and
I've found about the osg::State::setAbortRenderingPtr(bool*). That indeed
cancels the current frame, but it causes the viewer to get locked up waiting
for a mutex to become available in the Renderer::ThreadSafeQueue::takeFront()
function called from the Renderer::draw() function.
I've tried setting the abortRenderPtr to NULL every frame (using the FRAME
event on osgGA::GUIEventAdapter) and setting it to NULL immediately after it's
been checked in RenderLeaf::render, though that doesn't seem to change
anything. The wait function still takes control.
I've read that the setAbortRenderingPtr function is old, but is there any
knowledge about how it's supposed to be used?
Also, if that doesn't seem like the solution for my scenario, does anyone have
any suggestions?
Thanks!
- Ben
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org