Re: [osg-users] Rendering threads and scene graph updates.
Thanks all for the response. Finally i opted for a renderthread, because of some troubles doing it on a message loop basis. If my program call frame when it receives a message, it seems that the last event is not processed until the next call to frame, i suspect some interference with the checkEvent routine, perhaps not pumping the event that do frame to be called. I hope calling GetMessage (win32) from two threads would not have any unsolvable problems. Then, i use a Mutex for sincronize my main thread (that modifies the SG, adding nodes to a group) with the render loop in order to guarantee no cull /draw interference. It just worked for me. I did a loop to add 1000 nodes to a group node, and there seems not to be anything wrong. Of course, having a node with 1000 children looks like a bad idea, the cull traversal eats the framerate and avoid real time moving, specially when i see all of them. But scene structuration is another problem, and i must find another scene graph hierarchy for this use case. Thanks for the tips. 2007/7/5, Paul Martz [EMAIL PROTECTED]: When writing the Quick Start Guide, I opted to err on the side of conservatism. So, if you only modify STATIC scene graph nodes during update(), you can be assured that is a safe operation, and will almost certainly be a safe operation in future OSG releases. In the current incarnation of OSG, however, it's safe to modify STATIC nodes anytime you're not inside cull/draw. Furthermore, you can even modify nodes that are DYNAMIC while you're in the draw() traversal. This is a) more advanced stuff, and b) possibly subject to change in future OSG releases. -Paul -- *From:* [EMAIL PROTECTED] [mailto: [EMAIL PROTECTED] *On Behalf Of *Himar Carmona *Sent:* Tuesday, July 03, 2007 6:37 PM *To:* osg users *Subject:* [osg-users] Rendering threads and scene graph updates. Hi, i'm working with OSG on Windows. I'm designing a Geo viewer that use OSG internally for rendering purposes, and i have some questions about how the modification of the scene graph must be done to be safe with the cull and draw traversals. After reading the Quick Start Guide and the DatabasePager code and looking at the osg mail archive, what i've found so far is that it is possible to modify the scene graph inside an update callback and that it is the recommended approach (viewer seems to treat databasePager as a special case and don't use update callback). I'm right with that or have i misunderstood something? Until now i have been working with a render thread that i start after the window is created. But after reading a comment in the checkevents method of GraphicsWindowWin32 that says it must be called from the main thread and knowing that Win32 don't like much that different threads access the message loop (as checkevents does), i'm thinking about the possibilty of doing the render from the main thread ( e.g. using WM_TIMER and calling viewer::frame() , i don't have access to the app message loop). Is this possible? The examples i have seen so far use either a render thread (osgviewerMFC) or a custom message loop (osgViewerGLUT). I'm seeking for the possibility of avoiding to implement a custom Update Callback for doing the updates of the scenegraph, and make the changes directly to the scenegraph. It will free me for implementing the changes queues in the update callback (a solution mentioned in a two years old osg mail message) and will simplify my design greatly. The Quick Start Guide mentioned that this is possible, but also mentioned that this requires modifications to the main rendering loop. What else have to be keep in mind? Thanks in advance, Himar. ___ osg-users mailing list osg-users@openscenegraph.net http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/ ___ osg-users mailing list osg-users@openscenegraph.net http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
Re: [osg-users] Rendering threads and scene graph updates.
On 7/6/07, Himar Carmona [EMAIL PROTECTED] wrote: It just worked for me. I did a loop to add 1000 nodes to a group node, and there seems not to be anything wrong. Of course, having a node with 1000 children looks like a bad idea, the cull traversal eats the framerate and avoid real time moving, specially when i see all of them. But scene structuration is another problem, and i must find another scene graph hierarchy for this use case. You should aim for a balanced tree with your scene graph, typically this will be a quad tree, where you have four children per group. The osgUil::Optimizer spatialize groups pass can help you with this. Robert. ___ osg-users mailing list osg-users@openscenegraph.net http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
RE: [osg-users] Rendering threads and scene graph updates.
When writing the Quick Start Guide, I opted to err on the side of conservatism. So, if you only modify STATIC scene graph nodes during update(), you can be assured that is a safe operation, and will almost certainly be a safe operation in future OSG releases. In the current incarnation of OSG, however, it's safe to modify STATIC nodes anytime you're not inside cull/draw. Furthermore, you can even modify nodes that are DYNAMIC while you're in the draw() traversal. This is a) more advanced stuff, and b) possibly subject to change in future OSG releases. -Paul _ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Himar Carmona Sent: Tuesday, July 03, 2007 6:37 PM To: osg users Subject: [osg-users] Rendering threads and scene graph updates. Hi, i'm working with OSG on Windows. I'm designing a Geo viewer that use OSG internally for rendering purposes, and i have some questions about how the modification of the scene graph must be done to be safe with the cull and draw traversals. After reading the Quick Start Guide and the DatabasePager code and looking at the osg mail archive, what i've found so far is that it is possible to modify the scene graph inside an update callback and that it is the recommended approach (viewer seems to treat databasePager as a special case and don't use update callback). I'm right with that or have i misunderstood something? Until now i have been working with a render thread that i start after the window is created. But after reading a comment in the checkevents method of GraphicsWindowWin32 that says it must be called from the main thread and knowing that Win32 don't like much that different threads access the message loop (as checkevents does), i'm thinking about the possibilty of doing the render from the main thread ( e.g. using WM_TIMER and calling viewer::frame() , i don't have access to the app message loop). Is this possible? The examples i have seen so far use either a render thread (osgviewerMFC) or a custom message loop (osgViewerGLUT). I'm seeking for the possibility of avoiding to implement a custom Update Callback for doing the updates of the scenegraph, and make the changes directly to the scenegraph. It will free me for implementing the changes queues in the update callback (a solution mentioned in a two years old osg mail message) and will simplify my design greatly. The Quick Start Guide mentioned that this is possible, but also mentioned that this requires modifications to the main rendering loop. What else have to be keep in mind? Thanks in advance, Himar. ___ osg-users mailing list osg-users@openscenegraph.net http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
Re: [osg-users] Rendering threads and scene graph updates.
On 7/4/07, Alberto Luaces [EMAIL PROTECTED] wrote: El Miércoles 04 Julio 2007, Himar Carmona escribió: I'm seeking for the possibility of avoiding to implement a custom Update Callback for doing the updates of the scenegraph, and make the changes directly to the scenegraph. As far as I know, there is nothing wrong with modifying the scenegraph before the cull and draw traversals, something as while (!viewer.done()) { /*Do here your updating stuff*/ viewer.frame(); } Yep Alberto is correct, I'll add a bit more explanation and a few caveats. First up I'll expand viewer.frame() out into it constiiuent parts (see the source code to see yourself): while(!viewer.done()) { viewer.advance(); // increment the frame count and frame time viewer.eventTraversal(); // run the event handles and event traversal viewer.updateTraversal(); // run the update traversal viewer.renderingTraversals(); // run the rendering traverals } In the Viewer threading models SingleThreaded and ThreadPerGraphicsContext the renderingTraversals() will run all the rendering traversals and then only complete once they are all complete, this includes all associated threads if multi-threading. Once renderingTraversals() is complete you are free to modify any parts of the scene graph, in fact you are free to modify any point in the above main loop. With the DrawThreadPerContext and CullThreadPerCameraDrawThreadPerContext the renderingTraversals() method can return before the drawing threads are complete, and under these conditions you have to be more careful about what you modify - you should not modify any StateSet/StateAttribute or Drawables which are label with STATIC DataVariance. If you wish to modify these parts you must do a setDataVariance(DYNAMIC) on these objects and do so before they are introduced into the running viewer. Robert. ___ osg-users mailing list osg-users@openscenegraph.net http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
[osg-users] Rendering threads and scene graph updates.
Hi, i'm working with OSG on Windows. I'm designing a Geo viewer that use OSG internally for rendering purposes, and i have some questions about how the modification of the scene graph must be done to be safe with the cull and draw traversals. After reading the Quick Start Guide and the DatabasePager code and looking at the osg mail archive, what i've found so far is that it is possible to modify the scene graph inside an update callback and that it is the recommended approach (viewer seems to treat databasePager as a special case and don't use update callback). I'm right with that or have i misunderstood something? Until now i have been working with a render thread that i start after the window is created. But after reading a comment in the checkevents method of GraphicsWindowWin32 that says it must be called from the main thread and knowing that Win32 don't like much that different threads access the message loop (as checkevents does), i'm thinking about the possibilty of doing the render from the main thread (e.g. using WM_TIMER and calling viewer::frame() , i don't have access to the app message loop). Is this possible? The examples i have seen so far use either a render thread (osgviewerMFC) or a custom message loop (osgViewerGLUT). I'm seeking for the possibility of avoiding to implement a custom Update Callback for doing the updates of the scenegraph, and make the changes directly to the scenegraph. It will free me for implementing the changes queues in the update callback (a solution mentioned in a two years old osg mail message) and will simplify my design greatly. The Quick Start Guide mentioned that this is possible, but also mentioned that this requires modifications to the main rendering loop. What else have to be keep in mind? Thanks in advance, Himar. ___ osg-users mailing list osg-users@openscenegraph.net http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/