diff --git a/src/Canvas/canvas.cxx b/src/Canvas/canvas.cxx index d0f4b9567..2efe42638 100644 --- a/src/Canvas/canvas.cxx +++ b/src/Canvas/canvas.cxx @@ -49,17 +49,13 @@ class Canvas::DrawCallback: virtual void operator()(osg::RenderInfo& renderInfo) const { - const std::string VG_SIGNAL = "/sim/signals/vg-initialized"; + const long frame = renderInfo.getView()->getFrameStamp() + ->getFrameNumber(); - if( fgGetBool(VG_SIGNAL) ) - { - fgSetBool(VG_SIGNAL, false); - // If OpenVG has been initialized we need to redraw the frame, because - // initializing has happened instead of rendering - _canvas->_render_dirty = true; - } - else - _canvas->_render_dirty = false; + // If OpenVG has been initialized we need to redraw the frame, because + // initializing has happened instead of rendering. + // Otherwise we just reset the _render_dirty flag. + _canvas->_render_dirty = (frame == fgGetLong(canvas::VG_INIT_SIGNAL)); } protected: diff --git a/src/Canvas/canvas_fwd.hpp b/src/Canvas/canvas_fwd.hpp index 56b40fcb2..004fb253b 100644 --- a/src/Canvas/canvas_fwd.hpp +++ b/src/Canvas/canvas_fwd.hpp @@ -36,6 +36,8 @@ typedef boost::weak_ptr PropertyBasedElementWeakPtr; namespace canvas { + const std::string VG_INIT_SIGNAL = "/sim/signals/vg-initialized-frame"; + class Group; class Image; class MouseEvent; diff --git a/src/Canvas/elements/path.cxx b/src/Canvas/elements/path.cxx index 31cc52d27..65031cfd2 100644 --- a/src/Canvas/elements/path.cxx +++ b/src/Canvas/elements/path.cxx @@ -17,6 +17,7 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "path.hxx" +#include #include #include
@@ -170,7 +171,10 @@ namespace canvas vgCreateContextSH(vp[2], vp[3]); _vg_initialized = true; - fgSetBool("/sim/signals/vg-initialized", true); + + fgSetInt( canvas::VG_INIT_SIGNAL, + renderInfo.getView()->getFrameStamp()->getFrameNumber() ); + return; }