[osg-users] Single scene, multiple viewers : problem with texture

8 views
Skip to first unread message

Aurelien Albert

unread,
Nov 28, 2011, 11:15:19 AM11/28/11
to osg-...@lists.openscenegraph.org
Hi,

I've got a problem when viewing the same scene from two different viewers :

- Viewer A with Camera A
- Viewer B with Camera B

I load a node with :


Code:
osg::ref_ptr<osg::Node> pNode = osgDB::readNodeFile("...");

Then I do :


Code:
p_viewerA->setCamera(p_cameraA);
p_viewerA->setSceneData(pNode);

p_viewerB->setCamera(p_cameraB);
p_viewerB->setSceneData(pNode);


Everything works fine, but when viewer B is deleted, pNode's textures are no more rendered in viewer A (geometry is still rendered correctly).

Is there anything special to do to share data between two viewer ?

Thank you!

Cheers,
Aurelien

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

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

David Glenn

unread,
Nov 28, 2011, 4:23:32 PM11/28/11
to osg-...@lists.openscenegraph.org

Aurelien wrote:
> Hi,
>
> I've got a problem when viewing the same scene from two different viewers :
>
> - Viewer A with Camera A
> - Viewer B with Camera B
>
> I load a node with :
>
>
> Code:
> osg::ref_ptr<osg::Node> pNode = osgDB::readNodeFile("...");
>
>
>
> Then I do :
>
>
> Code:
> p_viewerA->setCamera(p_cameraA);
> p_viewerA->setSceneData(pNode);
>
> p_viewerB->setCamera(p_cameraB);
> p_viewerB->setSceneData(pNode);
>
>
>
>
> Everything works fine, but when viewer B is deleted, pNode's textures are no more rendered in viewer A (geometry is still rendered correctly).
>
> Is there anything special to do to share data between two viewer ?
>
> Thank you!
>
> Cheers,
> Aurelien


Well, I would look at it differently (like using slave cameras), but in this case, have you tried dynamically linking the node?

D Glenn

------------------------
David Glenn
---------------
D Glenn 3D Computer Graphics &amp; Media Systems.
www.dglenn.com

------------------
Read this topic online here:

http://forum.openscenegraph.org/viewtopic.php?p=44083#44083

Aurelien Albert

unread,
Nov 29, 2011, 3:31:21 AM11/29/11
to osg-...@lists.openscenegraph.org
Hi,

Can you explain what you mean by "dynamically linking the node" ?

------------------
Read this topic online here:

http://forum.openscenegraph.org/viewtopic.php?p=44088#44088

Aurelien Albert

unread,
Nov 29, 2011, 5:22:57 AM11/29/11
to osg-...@lists.openscenegraph.org
I found the solution :

Using the osgUtil::Optimizer::TextureVisitor to set all textures to "UnrefImageAfterApply = false"

------------------
Read this topic online here:

http://forum.openscenegraph.org/viewtopic.php?p=44104#44104

Robert Osfield

unread,
Nov 29, 2011, 10:48:14 AM11/29/11
to osg-...@lists.openscenegraph.org
HI Aurelien,

You should use multiple View's within a single CompositeViewer for
doing this rather than multiple viewers.

Robert.

Aurelien Albert

unread,
Nov 29, 2011, 10:55:21 AM11/29/11
to osg-...@lists.openscenegraph.org
Hi Robert,

In my application, there is a "main viewer" to edit the scene, and the user can open/close secondary viewer windows.

These secondary viewer windows are not limited in number (sure, there is hardware limits...) and the camera is independant from the other viewers (to see different point of view).

So when user open a new secondary viewer window, I create a new viewer instance, a new camera, and the context is shared with the main window.

When user close a secondary window, I delete the associated viewer to release some resources.

The secondary windows can also be resized, so the viewport is also independant.

Each viewer (main and secondary) are embeded in a Qt widget.

Is there any way to do this with a composite viewer ?

------------------
Read this topic online here:

http://forum.openscenegraph.org/viewtopic.php?p=44119#44119

Robert Osfield

unread,
Jan 6, 2012, 5:46:32 AM1/6/12
to osg-...@lists.openscenegraph.org
Hi Aurelien,

Sorry for the slow reply, no trying to catch up on my email backlog...

osgViewer::CompositeViewer is designed for applications that have
multiple Views and your usage model fits this perfectly. The only
thing to be careful of is when you are adding and removing View's from
the CompositeViewer you should do is calling stopThreading() on the
viewer prior to adding or removing views, then call startThreading()
afterwards. If you are running SingleThreaded or
CullDrawThreadPerContext you won't need to worry about stop and
starting threads.

Robert.

Reply all
Reply to author
Forward
0 new messages