Re: [osg-users] event callback after viewer is done

2015-10-08 Thread Robert Osfield
Hi Riccardo,

On 8 October 2015 at 15:13, Riccardo Corsi 
wrote:

> I see your point, nevertheless do you think that either:
> - having the event callback called with an "about-to-exit" event
> - having a custom callback to added and called by the viewer right before
> exiting
>
> would be a sensible addition to osg?
>

Adding a feature to the core OSG to address the needs of a single end user
that may or may not need this feature is not something I feel is
appropriate.

If there were no other way to solve the particular problem you are trying
to resolve it might be a compelling but there are number of different ways
to resolve the issue at your end:

   The exit from the application is entirely within end user control so you
can decide when it happens and what happens when you want to exit.

   The osgGA::Event/GUIEventAdapter system is extensible so end users can
subclass and dispatch their own events and have the event callbacks catch
these.

   After exiting the main frame/event loop you can call what ever you want
to call to do clean up.

These aren't the only ways either.

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


Re: [osg-users] event callback after viewer is done

2015-10-08 Thread Riccardo Corsi
Hi Robert,

I see your point, nevertheless do you think that either:
- having the event callback called with an "about-to-exit" event
- having a custom callback to added and called by the viewer right before
exiting

would be a sensible addition to osg?

Thanks.
ricky



On Wed, Oct 7, 2015 at 10:17 AM, Robert Osfield 
wrote:

> Hi Ricky,
>
> I don't have any suggestion for an alternate design as I still really know
> enough about ImGui.  My suggestion would be to look closely at the crash
> and why it's happening.
>
> Requiring different calls to be be done in a particular order is not
> unusual but having things crash when one traversal isn't followed by
> another suggests a problem somewhere in the design/implementation.
>
> Robert.
>
> On 7 October 2015 at 08:50, Riccardo Corsi 
> wrote:
>
>> Hi Robert,
>>
>> what I'm trying to do is integrating the ImGui framework and render it
>> natively through osg primitives.
>> This gui works in immediate mode, meaning you have to call the code to
>> create your widgets every frame,
>> which is what I do in the custom code in the frame loop (as this changes
>> for every application).
>> All the rest is handled in custom callbacks attached to some nodes.
>>
>> Basically, ImGui needs these things to happen in order at every frame
>> 1. getting inputs (done in the event callback )
>> 2. call to NewFrame() (called on the "FRAME" event, which is the last one
>> received in the event callback)
>> 3. code to create widgets (explicit in the main loop)
>> 4. call to Render() which produces geometries to be rendered by osg (this
>> is done in the update callback)
>>
>> Now, a call to the code that creates widgets (3.) without a proper
>> NewFrame() (2.) causes a crash.
>> When osgViewer is done, I don't get the event callback, and the code
>> which creates the gui crashes.
>>
>> Any suggestion for an alternative design?
>>
>> Thank you,
>> Ricky
>>
>>
>>
>> On Tue, Oct 6, 2015 at 8:56 PM, Robert Osfield 
>> wrote:
>>
>>> Hi Ricky,
>>>
>>> I don't know what is in your event callback but for exit to cause a
>>> crash it sounds like something is probably not being managed robustly.  As
>>> I know so little I can't provide any specific advice.
>>>
>>> One possibility might be to call viewer.eventTravseral() after the main
>>> rendering loop.  I can't help be feel there is something amiss in the way
>>> your are managing your event callback and it's associated faculties, and
>>> suspect a small redesign could probably resolve the issue.
>>>
>>> Robert.
>>>
>>> On 6 October 2015 at 18:03, Riccardo Corsi 
>>> wrote:
>>>
 Hi all,

 I have an event callback which needed to be called before some custom
 code I call in the main application loop, something like:

 while()
 {
 viewer.eventTraversal();  // << needed callback here

 // custom code
 // prepare stuff to be drawn during next frames

 viewer.updateTraversal();
 // ...
 }

 When the viewer is about to exit, the event callbacks are not called.
 In my case the callback is needed instead,
 not to cause a segfault to the custom code between osg calls.

 The obvious solution is to place the callback directly in the main loop,
 but I'd like to avoid that
 (to keep it more "transparent", as it's a kind of framework to be used
 in several applications).

 Have you got any suggestion?
 Thank you!
 Ricky

 ___
 osg-users mailing list
 osg-users@lists.openscenegraph.org

 http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


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


Re: [osg-users] event callback after viewer is done

2015-10-07 Thread Robert Osfield
Hi Ricky,

I don't have any suggestion for an alternate design as I still really know
enough about ImGui.  My suggestion would be to look closely at the crash
and why it's happening.

Requiring different calls to be be done in a particular order is not
unusual but having things crash when one traversal isn't followed by
another suggests a problem somewhere in the design/implementation.

Robert.

On 7 October 2015 at 08:50, Riccardo Corsi 
wrote:

> Hi Robert,
>
> what I'm trying to do is integrating the ImGui framework and render it
> natively through osg primitives.
> This gui works in immediate mode, meaning you have to call the code to
> create your widgets every frame,
> which is what I do in the custom code in the frame loop (as this changes
> for every application).
> All the rest is handled in custom callbacks attached to some nodes.
>
> Basically, ImGui needs these things to happen in order at every frame
> 1. getting inputs (done in the event callback )
> 2. call to NewFrame() (called on the "FRAME" event, which is the last one
> received in the event callback)
> 3. code to create widgets (explicit in the main loop)
> 4. call to Render() which produces geometries to be rendered by osg (this
> is done in the update callback)
>
> Now, a call to the code that creates widgets (3.) without a proper
> NewFrame() (2.) causes a crash.
> When osgViewer is done, I don't get the event callback, and the code which
> creates the gui crashes.
>
> Any suggestion for an alternative design?
>
> Thank you,
> Ricky
>
>
>
> On Tue, Oct 6, 2015 at 8:56 PM, Robert Osfield 
> wrote:
>
>> Hi Ricky,
>>
>> I don't know what is in your event callback but for exit to cause a crash
>> it sounds like something is probably not being managed robustly.  As I know
>> so little I can't provide any specific advice.
>>
>> One possibility might be to call viewer.eventTravseral() after the main
>> rendering loop.  I can't help be feel there is something amiss in the way
>> your are managing your event callback and it's associated faculties, and
>> suspect a small redesign could probably resolve the issue.
>>
>> Robert.
>>
>> On 6 October 2015 at 18:03, Riccardo Corsi 
>> wrote:
>>
>>> Hi all,
>>>
>>> I have an event callback which needed to be called before some custom
>>> code I call in the main application loop, something like:
>>>
>>> while()
>>> {
>>> viewer.eventTraversal();  // << needed callback here
>>>
>>> // custom code
>>> // prepare stuff to be drawn during next frames
>>>
>>> viewer.updateTraversal();
>>> // ...
>>> }
>>>
>>> When the viewer is about to exit, the event callbacks are not called.
>>> In my case the callback is needed instead,
>>> not to cause a segfault to the custom code between osg calls.
>>>
>>> The obvious solution is to place the callback directly in the main loop,
>>> but I'd like to avoid that
>>> (to keep it more "transparent", as it's a kind of framework to be used
>>> in several applications).
>>>
>>> Have you got any suggestion?
>>> Thank you!
>>> Ricky
>>>
>>> ___
>>> osg-users mailing list
>>> osg-users@lists.openscenegraph.org
>>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>>
>>>
>>
>> ___
>> osg-users mailing list
>> osg-users@lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] event callback after viewer is done

2015-10-07 Thread Riccardo Corsi
Hi Robert,

what I'm trying to do is integrating the ImGui framework and render it
natively through osg primitives.
This gui works in immediate mode, meaning you have to call the code to
create your widgets every frame,
which is what I do in the custom code in the frame loop (as this changes
for every application).
All the rest is handled in custom callbacks attached to some nodes.

Basically, ImGui needs these things to happen in order at every frame
1. getting inputs (done in the event callback )
2. call to NewFrame() (called on the "FRAME" event, which is the last one
received in the event callback)
3. code to create widgets (explicit in the main loop)
4. call to Render() which produces geometries to be rendered by osg (this
is done in the update callback)

Now, a call to the code that creates widgets (3.) without a proper
NewFrame() (2.) causes a crash.
When osgViewer is done, I don't get the event callback, and the code which
creates the gui crashes.

Any suggestion for an alternative design?

Thank you,
Ricky



On Tue, Oct 6, 2015 at 8:56 PM, Robert Osfield 
wrote:

> Hi Ricky,
>
> I don't know what is in your event callback but for exit to cause a crash
> it sounds like something is probably not being managed robustly.  As I know
> so little I can't provide any specific advice.
>
> One possibility might be to call viewer.eventTravseral() after the main
> rendering loop.  I can't help be feel there is something amiss in the way
> your are managing your event callback and it's associated faculties, and
> suspect a small redesign could probably resolve the issue.
>
> Robert.
>
> On 6 October 2015 at 18:03, Riccardo Corsi 
> wrote:
>
>> Hi all,
>>
>> I have an event callback which needed to be called before some custom
>> code I call in the main application loop, something like:
>>
>> while()
>> {
>> viewer.eventTraversal();  // << needed callback here
>>
>> // custom code
>> // prepare stuff to be drawn during next frames
>>
>> viewer.updateTraversal();
>> // ...
>> }
>>
>> When the viewer is about to exit, the event callbacks are not called.
>> In my case the callback is needed instead,
>> not to cause a segfault to the custom code between osg calls.
>>
>> The obvious solution is to place the callback directly in the main loop,
>> but I'd like to avoid that
>> (to keep it more "transparent", as it's a kind of framework to be used in
>> several applications).
>>
>> Have you got any suggestion?
>> Thank you!
>> Ricky
>>
>> ___
>> osg-users mailing list
>> osg-users@lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] event callback after viewer is done

2015-10-06 Thread Robert Osfield
Hi Ricky,

I don't know what is in your event callback but for exit to cause a crash
it sounds like something is probably not being managed robustly.  As I know
so little I can't provide any specific advice.

One possibility might be to call viewer.eventTravseral() after the main
rendering loop.  I can't help be feel there is something amiss in the way
your are managing your event callback and it's associated faculties, and
suspect a small redesign could probably resolve the issue.

Robert.

On 6 October 2015 at 18:03, Riccardo Corsi 
wrote:

> Hi all,
>
> I have an event callback which needed to be called before some custom code
> I call in the main application loop, something like:
>
> while()
> {
> viewer.eventTraversal();  // << needed callback here
>
> // custom code
> // prepare stuff to be drawn during next frames
>
> viewer.updateTraversal();
> // ...
> }
>
> When the viewer is about to exit, the event callbacks are not called.
> In my case the callback is needed instead,
> not to cause a segfault to the custom code between osg calls.
>
> The obvious solution is to place the callback directly in the main loop,
> but I'd like to avoid that
> (to keep it more "transparent", as it's a kind of framework to be used in
> several applications).
>
> Have you got any suggestion?
> Thank you!
> Ricky
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] event callback after viewer is done

2015-10-06 Thread Riccardo Corsi
Hi all,

I have an event callback which needed to be called before some custom code
I call in the main application loop, something like:

while()
{
viewer.eventTraversal();  // << needed callback here

// custom code
// prepare stuff to be drawn during next frames

viewer.updateTraversal();
// ...
}

When the viewer is about to exit, the event callbacks are not called.
In my case the callback is needed instead,
not to cause a segfault to the custom code between osg calls.

The obvious solution is to place the callback directly in the main loop,
but I'd like to avoid that
(to keep it more "transparent", as it's a kind of framework to be used in
several applications).

Have you got any suggestion?
Thank you!
Ricky
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org