Thanks for your effort.

The code wasn't pseudo code. It compiled well. Of course it is useless 
but it shows my problem.
Here is what i found out:

===================================

    osg::Group* root = new osg::Group();
    Viewer* wnds = new Viewer();
    wnds->setSceneData(root); //  <--- crashing here
    wnds->setUpViewOnSingleScreen();
    wnds->realize();

===================================

    Viewer wnds;
    wnds.setUpViewOnSingleScreen();
    wnds.realize(); //  <--- crashing here

===================================

    osg::Group* root = new osg::Group();
    Viewer wnds;
    wnds.setSceneData(root);
    wnds.setUpViewOnSingleScreen();
    wnds.realize();

//working!!!!!!!

===================================

Comparing example 1 and 3:
I was wondering, whats the big difference here between using a pointer 
(doesn't matter if a ref_ptr or plain C-pointer) and the stack. It 
should just be a matter of where i want my memory to be allocated and 
how to proceed with the memory, if the variable or pointer gets out of 
scope. Is the new operator overloaded?

In example 2 it seems a call to setSceneData() is very important for the 
viewer class....

Any comments?

However, nice to see it working now.

Thanks
 -- Matthias




Robert Osfield wrote:
> Hi Mathias,
>
> On 8/29/07, Matthias Weigand <[EMAIL PROTECTED]> wrote:
>   
>> thanks for your reply. I switched to using the Viewer class. The code is:
>>
>> #include <osgViewer/Viewer>
>> using namespace osg;
>> int main()
>> {
>>     osgViewer::Viewer* wnds = new osgViewer::Viewer();
>>     wnds->setUpViewOnSingleScreen();
>>     wnds->realize();
>>     return 0;
>> }
>>
>> Calling realize() crashes my app with a segfault.
>> No error message is written to stdout or stderr during execution.
>>
>> I'm using Visual Studio 8 on WinXP Pro SP2 (32-bit).
>> My OpenSceneGraph version is the official stable 2.0.
>> I build up a clean project with include-dir
>> D:\SDK\OpenSceneGraph\include and lib-dir D:\SDK\OpenSceneGraph\lib and
>> osg.lib as additional library. No ATL, no MFC, nothing.
>>
>> What may cause such a problem?
>>     
>
> I presume your code extract is psedo code as it has a number of issues.
>
> First up if you are going to create a viewer on the heap via new  use
> ref_ptr<Viewer> instead of a C pointer to make sure the memory is
> cleaned up correctly.
>
> Second, there is now scene assignment i.e. viewer.setSceneData(mySceneGraph);
>
> Third, your realize the viewer but then do run any frame loop of any
> kind, so you at minimum need to add a viewer.run().
>
> All of this illustrated in the examples.
>
> Robert.
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>   

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to