[osg-users] Add / Remove Slave

2009-01-20 Thread Adrian Egli OpenSceneGraph (3D)
Hi

i am wondering who i can add / remove slave cameras at runtime. with
different rendering context, embeded full screen, on different screens. I
get opengl state bugs, do i need to share opengl from master camera ? can i
not remove the very master camera? or what is the correct concept.

adrian

-- 

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


Re: [osg-users] Add / Remove Slave

2009-01-21 Thread Robert Osfield
Hi Adrian,

If you want to add and remove slaves from a view at runtime you will
need to stop the threading of the viewer via viewer.stopThreading(),
then add/removeSlave() call realize on any new graphics contexts then
call startThreading();

Robert.

On Wed, Jan 21, 2009 at 7:27 AM, Adrian Egli OpenSceneGraph (3D)
<3dh...@gmail.com> wrote:
> Hi
>
> i am wondering who i can add / remove slave cameras at runtime. with
> different rendering context, embeded full screen, on different screens. I
> get opengl state bugs, do i need to share opengl from master camera ? can i
> not remove the very master camera? or what is the correct concept.
>
> adrian
>
> --
> 
> Adrian Egli
>
> ___
> 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] Add / Remove Slave

2009-01-21 Thread Adrian Egli OpenSceneGraph (3D)
Thanks a lot

/adrian

2009/1/21 Robert Osfield 

> Hi Adrian,
>
> If you want to add and remove slaves from a view at runtime you will
> need to stop the threading of the viewer via viewer.stopThreading(),
> then add/removeSlave() call realize on any new graphics contexts then
> call startThreading();
>
> Robert.
>
> On Wed, Jan 21, 2009 at 7:27 AM, Adrian Egli OpenSceneGraph (3D)
> <3dh...@gmail.com> wrote:
> > Hi
> >
> > i am wondering who i can add / remove slave cameras at runtime. with
> > different rendering context, embeded full screen, on different screens. I
> > get opengl state bugs, do i need to share opengl from master camera ? can
> i
> > not remove the very master camera? or what is the correct concept.
> >
> > adrian
> >
> > --
> > 
> > Adrian Egli
> >
> > ___
> > 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
>



-- 

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


Re: [osg-users] Add / Remove Slave

2009-01-21 Thread Adrian Egli OpenSceneGraph (3D)
osg::ref_ptr traits = new
osg::GraphicsContext::Traits;
traits->hostName = si.hostName;
traits->displayNum = si.displayNum;
traits->screenNum = si.screenNum;
traits->x = 0;
traits->y = 0;
traits->width = width;
traits->height = height;
traits->windowDecoration = false;
traits->doubleBuffer = true;
traits->sharedContext =
m_IWebaddon3D->getWebaddonRenderer()->getOSGViewer()->getCamera()->getGraphicsContext();

i share the context, when i remove the slave, i will loose all textures
(:-))


2009/1/21 Adrian Egli OpenSceneGraph (3D) <3dh...@gmail.com>

> Thanks a lot
>
> /adrian
>
> 2009/1/21 Robert Osfield 
>
> Hi Adrian,
>>
>> If you want to add and remove slaves from a view at runtime you will
>> need to stop the threading of the viewer via viewer.stopThreading(),
>> then add/removeSlave() call realize on any new graphics contexts then
>> call startThreading();
>>
>> Robert.
>>
>> On Wed, Jan 21, 2009 at 7:27 AM, Adrian Egli OpenSceneGraph (3D)
>> <3dh...@gmail.com> wrote:
>> > Hi
>> >
>> > i am wondering who i can add / remove slave cameras at runtime. with
>> > different rendering context, embeded full screen, on different screens.
>> I
>> > get opengl state bugs, do i need to share opengl from master camera ?
>> can i
>> > not remove the very master camera? or what is the correct concept.
>> >
>> > adrian
>> >
>> > --
>> > 
>> > Adrian Egli
>> >
>> > ___
>> > 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
>>
>
>
>
> --
> 
> Adrian Egli
>



-- 

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


Re: [osg-users] Add / Remove Slave

2009-01-21 Thread Jean-Sébastien Guay

Hi Adrian,

i share the context, when i remove the slave, i will loose all textures 
(:-))


This has been discussed a lot in the past, search the archives. Hint: 
disable "unref textures on apply".


Hope this helps,

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.webhop.org/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Add / Remove Slave

2009-01-21 Thread Adrian Egli OpenSceneGraph (3D)
Thanks for the replay, but i can not find any topic corresponding this
contex. I don't know what's going wrong, but
if i share an openGL context, say from my master camera and then i suddenly
like to close a slave cam, i shouldn't
close the shared context. because i still have the current context in use,
right? It doesn't delete the master's context, but
i loose the textures, may this is what your like to give as hint. but i am
not sure whether it removes the textures only.

/adrian

2009/1/21 Jean-Sébastien Guay 

> Hi Adrian,
>
>  i share the context, when i remove the slave, i will loose all textures
>> (:-))
>>
>
> This has been discussed a lot in the past, search the archives. Hint:
> disable "unref textures on apply".
>
> Hope this helps,
>
> J-S
> --
> __
> Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
>   http://www.cm-labs.com/
>http://whitestar02.webhop.org/
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



-- 

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


Re: [osg-users] Add / Remove Slave

2009-01-21 Thread Robert Osfield
Hi Adrian,

The problem might well be that the outgoing context is cleaning up
it's scene graph and associated OpenGL without know that they are
shared.  You could remove the scene graph from the associated camera
before closing it to prevent the graphics window automatically cleanly
up all associate OpenGL objects.

Robert.

On Wed, Jan 21, 2009 at 4:14 PM, Adrian Egli OpenSceneGraph (3D)
<3dh...@gmail.com> wrote:
> Thanks for the replay, but i can not find any topic corresponding this
> contex. I don't know what's going wrong, but
> if i share an openGL context, say from my master camera and then i suddenly
> like to close a slave cam, i shouldn't
> close the shared context. because i still have the current context in use,
> right? It doesn't delete the master's context, but
> i loose the textures, may this is what your like to give as hint. but i am
> not sure whether it removes the textures only.
>
> /adrian
>
> 2009/1/21 Jean-Sébastien Guay 
>>
>> Hi Adrian,
>>
>>> i share the context, when i remove the slave, i will loose all textures
>>> (:-))
>>
>> This has been discussed a lot in the past, search the archives. Hint:
>> disable "unref textures on apply".
>>
>> Hope this helps,
>>
>> J-S
>> --
>> __
>> Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
>>   http://www.cm-labs.com/
>>http://whitestar02.webhop.org/
>> ___
>> osg-users mailing list
>> osg-users@lists.openscenegraph.org
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
>
> --
> 
> Adrian Egli
>
> ___
> 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] Add / Remove Slave

2009-01-21 Thread Adrian Egli OpenSceneGraph (3D)
100% right Robert, removing the scene data before closing the context solves
the problem

The code above should help others having similar issue in the future...

/adrian
***


m_IWebaddon3D->getWebaddonRenderer()->getOSGViewer()->stopThreading();
if ( ! m_isFullScreen) {
setupSlaves();

for (FullScreenSlaves::iterator it =
m_FullScreenSlaves.begin();it!=m_FullScreenSlaves.end();it++){
osg::View::Slave &slave =
m_IWebaddon3D->getWebaddonRenderer()->getOSGViewer()->getSlave(*it);

slave._camera->removeChildren(0,slave._camera->getNumChildren());

slave._camera->addChild(m_IWebaddon3D->getWebaddonRenderer()->getOSGViewer()->getSceneData());
}
} else {
for (FullScreenSlaves::iterator it =
m_FullScreenSlaves.begin();it!=m_FullScreenSlaves.end();it++){
osg::View::Slave &slave =
m_IWebaddon3D->getWebaddonRenderer()->getOSGViewer()->getSlave(*it);

slave._camera->removeChildren(0,slave._camera->getNumChildren());

m_IWebaddon3D->getWebaddonRenderer()->getOSGViewer()->removeSlave(*it);
}
 m_FullScreenSlaves.clear();
SAFE_FREE_REF(m_GraphicsContext_FullScreen);
 }
m_isFullScreen = ! m_isFullScreen;
 m_doToogleFullScreen = false;

m_IWebaddon3D->getWebaddonRenderer()->getOSGViewer()->updateSlaves();

m_IWebaddon3D->getWebaddonRenderer()->getOSGViewer()->startThreading();


2009/1/21 Robert Osfield 

> Hi Adrian,
>
> The problem might well be that the outgoing context is cleaning up
> it's scene graph and associated OpenGL without know that they are
> shared.  You could remove the scene graph from the associated camera
> before closing it to prevent the graphics window automatically cleanly
> up all associate OpenGL objects.
>
> Robert.
>
> On Wed, Jan 21, 2009 at 4:14 PM, Adrian Egli OpenSceneGraph (3D)
> <3dh...@gmail.com> wrote:
> > Thanks for the replay, but i can not find any topic corresponding this
> > contex. I don't know what's going wrong, but
> > if i share an openGL context, say from my master camera and then i
> suddenly
> > like to close a slave cam, i shouldn't
> > close the shared context. because i still have the current context in
> use,
> > right? It doesn't delete the master's context, but
> > i loose the textures, may this is what your like to give as hint. but i
> am
> > not sure whether it removes the textures only.
> >
> > /adrian
> >
> > 2009/1/21 Jean-Sébastien Guay 
> >>
> >> Hi Adrian,
> >>
> >>> i share the context, when i remove the slave, i will loose all textures
> >>> (:-))
> >>
> >> This has been discussed a lot in the past, search the archives. Hint:
> >> disable "unref textures on apply".
> >>
> >> Hope this helps,
> >>
> >> J-S
> >> --
> >> __
> >> Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
> >>   http://www.cm-labs.com/
> >>http://whitestar02.webhop.org/
> >> ___
> >> osg-users mailing list
> >> osg-users@lists.openscenegraph.org
> >>
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> >
> >
> >
> > --
> > 
> > Adrian Egli
> >
> > ___
> > 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
>



-- 

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