[osg-users] Wrong geode display on screen

147 views
Skip to first unread message

Sylvain Comtois

unread,
Jan 10, 2014, 8:48:10 AM1/10/14
to osg-...@lists.openscenegraph.org
Hi,

We have a pretty complex software, under windows, that have a window the user can close and open for 3D rendering with OSG.

When the user close the window we delete all OSG object except some node create from .osg or .ive files to speed up the next load process.

The first time the user open the window we create the viewer and we load the nodes and everything just work perfectly. When the user close the window, everything is delete and we keep some nodes in a table.

The next time the user open the window we recreate the viewer and we create new node and use again node store in the table. In this second or subsequent creation of the window we have some or all of the nodes, stock in the table, that are not display correctly. The nodes newly create are always corrects.

By example, if we have a table with four objects (car, plane, box and ball) the ball can be show in place of the car or sometime just nothing is showed.

We believe we using the correct geode because of the followings test: First we save the geode in osg file for the first time we open the window when the geode is correct and in the next time the geode is not correct. We compare the two files and the only difference are UniqueID MatricTransform_0 and UniqueID StateSet_0.

Second we draw a bounding box around the object and the bounding correspond to the object we expected to be show. We use the ComputeBoundVistor to find the dimensions of the object.

The software is also use in a realty center (cave) when in this configuration we use 4 cameras when each camera represent a wall of the cave. We have one master camera with three slaves cameras sharing the same scene data and the same viewer.

In this configuration we can also observe the problem but in a different manner. Some camera show the right geode and some show a wrong geode. We only have to move the geode from one camera to another to see the two representation of the geode. Like in one camera mode, the problem is never present the first time we open the windows.

To clear the osg environment, we only set all reference pointer we use to 0 (viewer, scenegraph, cameras, etc). We also verify in the debug log that the destructor of the viewer is called.

But according to the log, it seem the 'GraphicContext' is not completely close.

Do we have to do something else to perfectly clean all the OSG environment. Does OSG use internal cache table that we need to reset ?

Thank you!

Cheers,
Sylvain

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=57854#57854





_______________________________________________
osg-users mailing list
osg-...@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Robert Osfield

unread,
Apr 17, 2014, 11:56:42 AM4/17/14
to OpenSceneGraph Users
Hi Sylvain,

It sounds like the OpenGL object caches aren't being cleared when the
graphics context deletes (the OSG has to use these caches as you can't
delete OpenGL from any thread that can delete a scene graph object.)
There is lots of support within the OSG to try and catch this
properly, but there may be usage combinations that break this. I
really don't know enough about the specifics of your implementation to
know what might be amiss. You don't say which version of the OSG you
are using, older versions din't catch all the usage cases of closing
context, so I would suggest you are use a recent version of the OSG to
make sure you have the best chance of all the loop holes with
context/viewer destruction being closed.

Failing that then calling the osg::discardAllGLObjects(contextID) is a
brute force way of clearing all the caches.

Robert.

Sylvain Comtois

unread,
Apr 17, 2014, 12:59:16 PM4/17/14
to osg-...@lists.openscenegraph.org
Hi Robert,

We use the last stable release 3.2.

Thank you!

Cheers,
Sylvain

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=59037#59037

Robert Osfield

unread,
Apr 18, 2014, 3:20:43 AM4/18/14
to OpenSceneGraph Users
HI Sylvain,

I don't think there have been any changes to the clean up of GL
objects since 3.2. There must be something odd in the way that the
viewer is being closed down as I've tested the close/re-open of the
viewer pretty extensively in the past. I guess there could have been
a regression, but there is also ways lots of different ways end users
can do things, it could be that your usage model somehow bypasses all
the safety measures put in place.

Could you create an small example that illustrates the problem?

As a general note, I would recommend against creating and destructing
viewers/threads/contexts as a standard practice, typically it's better
for application performance if a viewer is constructed and windows
unmapped and viewer thread put to sleep when not needed.

Robert.

Sylvain Comtois

unread,
Apr 17, 2014, 11:33:17 AM4/17/14
to osg-...@lists.openscenegraph.org
Hi,

I finally found that the problem is related with the display list of drawables. When the viewer is delete all display list and gl context are destroy but the drawable are still existing and keep a reference to the context and the display list.

When we create the new viewer, we have new context and no displaylist. When the drawable is add to the new rendering tree and the context and display list reference exist in the display list (create by another drawable) exist, he use it but the display list correspond to the display list of another drawable.

So we decide to recreate the drawable when the viewer is recreate.

We also observe when we destroy the viewer, we must destroy the camera of the viewer before destroying the viewer itself. The problem is the viewer is destroying context before destroying cameras. When the context are destroy, they erase the display list cache. After when cameras are destroy they destroy the remaining scene graph tree and destroy drawable that cannot remove the display list from the context because the context are already erase the display list cache.

This will not be a problem if context are really destroy. But when we recreate the viewer, some old context are reuse with they old display list inside them.

I'm not 100% certain of what append inside OSG but destroying the cameras before the viewer solve my problem.

Thank you!

Cheers,
Sylvain

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=59023#59023

Robert Osfield

unread,
Apr 18, 2014, 9:15:05 AM4/18/14
to OpenSceneGraph Users
Hi Sylvan,

The Drawables that you keep around beyond the line of the view/context
are they detached from the viewer prior to it's destruction? Doing
this prevents the viewer/context cleanup from knowing that it needs to
clean up those Drawables so they are left with dangling GL object
id's.

The mechanism that viewer uses to to kick off the clean up of the
scene graph is to call node->releaseGLObjects(), this method is also
available on StateSet/StateAttribute and Drawable. Normally just
needs to call releaseGLObjects() on the root of the scene graph and
then all nodes and leaves will have the releaseGLObjects() called on
them so there is no need to call it explicitly.

However, it sounds like in your particular usage model you are keeping
scene graph objects around that have been used in a context but are no
longer assigned to the viewer so the normal clean up doesn't work.
Here you'll need to call releaseGLObjects() on these
nodes/drawables/statesets that are no longer assigned to the viewer,
call it prior to destructing the viewer/context.

Robert.
Reply all
Reply to author
Forward
0 new messages