HI Thibault,

I must admit I hadn't considered the configuration of some windows in
a CompositeViewer being disabled and later re-enabled.  There is code
that checks valid() on each frame to see if the window has been closed
completely, but... this isn't quite appropriate in your case as you
want to later bring it back alive.

One of the complications is that when multi-threading all the threads
have syncronization barriers that they all must join on each frame, if
a window is disabled in some way then these barriers will need
resetting with the new number of threads that are meant to join them.

I will need to ponder on this issue.  Most likely it'll need some
additions to GraphicsWindow and the thread managment and rendering
dispatch code in Viewer and CompositeViewer.

Robert.

On 6/21/07, Thibault Genessay <[EMAIL PROTECTED]> wrote:
Hi everybody,

I've just been hit by a nasty problem with OSG and wxWidgets. I have several
gl windows on different panes of a notebook, thus some of them are shown
while some of them are hidden. Those panes are shown/hidden on an
unpredictable basis because the user himself can select a tab, or detach, or
close the windows. The problem is that the wxWidgets implementation of
osgViewer::GraphicsContext::makeCurrentImplementation()
calls wxGLCanvas::MakeCurrent() which *requires* that the window be visible.
So at some point, this call fails.
Now I have thought of a few ways to work around the problem, but I need your
insights to pick the good one.

1) osgViewer::GraphicsContext::makeCurrent() returns a
bool, but this value is never checked and the rendering is triggered anyway.
See around line 1275 of CompositeViewer.cpp:

 Contexts::iterator itr;
    for(itr = contexts.begin();
        itr != contexts.end();
        ++itr)
    {
        if (_done) return;
        if (!((*itr)->getGraphicsThread())  &&
(*itr)->valid())
        {
            (*itr)->makeCurrent();
            (*itr)->runOperations();
            (*itr)->releaseContext();
        }
    }

So the question is: is it meaningful to return anything at all when
MakeCurrent() either fails or is due to fail ? I had modified wxWidgets so
the wxGLCanvas::MakeCurrent() would also return a bool, but it seems that
this would not help as the OSG does not use this value.

2) The condition to the inner block of this loop is that the context is
valid. I think I could manage my GraphicsContext implementation so that it
returns false when the canvas is hidden, but I'm not sure of the
implications, because of the comments on the semantics of the valid()
function:
        /** Return whether a valid and usable GraphicsContext has been
created.*/
So yes, the context has been created, yes it is usable if it's shown - and
not if it's hidden - but hiding makes it temporarily unavailable, and it
will be available again in the future. So is the comment unacurate ? In
which case I would have to return false in my valid() implementation. Or is
valid() supposed to return false until the context is created, and true at
all time after that point ? I'm asking this because I'm not sure of what the
rest of osgViewer's code expects.


To conclude, I would prefer the solution 2) because 1) requires a patch in
the OSG and a patch in wxWidgets, while 2) only requires me to modify my
code, but again it's a matter of semantics of the valid() function.

Thanks in advance

Thibault

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to