Hi Werner,
Alberto said:
This is the common scenario for realtime applications. On the other side
for GUI applications, usually the scene is static until the user does
something. In that case, you only call frame() after keyboard, mouse,
redraw events... and you save all that redundant computations. This is
not specific to OSG or OpenGL, but it is a typical difference between
realtime and GUI applications.
Note though that osgViewer has a setting called "run_frame_scheme" which
you can set using the environment variable OSG_RUN_FRAME_SCHEME to
ON_DEMAND or CONTINUOUS, as well as a max frame rate that you can set
using the environment variable OSG_RUN_MAX_FRAME_RATE to a frame rate or
0.0 for no capping. There are also functions in OSG's API to set these
two things programmatically.
More details here:
http://blog.openscenegraph.org/?p=134
and here:
http://thread.gmane.org/gmane.comp.graphics.openscenegraph.user/43693
In theory, for realtime applications, you want the frame rate to be 60hz
solid, i.e. no frame drops and no spikes over 60hz. This will keep all
movement and user input fluid. Generally the best way to ensure this is
to enable vsync either in your app or in your video card's driver
settings. In effect, as long as your scene is relatively light, capping
the frame rate to 60hz using vsync will leave CPU time to spare for
other apps. Only if you uncap the frame rate (disable vsync AND set
OSG_RUN_MAX_FRAME_RATE=0.0) will your frame rate run loose, drawing many
redundant frames and driving your CPU usage to 100%
In your case if you're making a modeling app or something where you
don't need to render new frames continuously, you could set
OSG_RUN_FRAME_SCHEME=ON_DEMAND (or the same setting through the API).
When doing this, event handlers (the trackball manipulator for example)
should call requestRedraw() when needed, which will make a new frame be
rendered. If you have other things that happen which need the scene to
be redrawn, I suggest you call requestRedraw() (on your osgViewer::View,
osgViewer::Viewer or osgGA::GUIActionAdapter if inside an event
handler) as well, so you're doing things in the standard way.
That way, you can simply use the viewer in the normal way calling
frame() all the time, and it will just do nothing if no requestRedraw()
was called since the last frame. I think this is what you were looking
for. It's just not the default way OSG works since most of the time it's
used for realtime apps (games, simulators, etc.). But it's flexible
enough to give you the option to use it the way you want.
Hope this helps,
J-S
--
______________________________________________________
Jean-Sebastien Guay [email protected]
http://www.cm-labs.com/
http://whitestar02.webhop.org/
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org