Hi Brad,
After the releaseGLContext() could you do a
osg::discardAllDeletedGLObjects() to make sure the cached GL object
handles are all removed, otherwise the new context will think these
handles are still valid and can be reused.
Robert.
On Thu, Jan 21, 2010 at 1:36 AM, Christiansen, Brad
brad.christian...@thalesgroup.com.au wrote:
Hi,
I forgot to mention that I am also calling releaseGLObjects on the
viewer.
i.e. When I show the window, if I already have a GraphicsWindows I call:
if(m_gw.valid()) {
m_viewer-releaseGLObjects();
m_gw-close();
}
I then create a new graphics window and set it on the viewer:
osg::ref_ptrosg::Referenced windata = new
osgViewer::GraphicsWindowWin32::WindowData(hwnd, true);
osg::ref_ptrosg::GraphicsContext::Traits traits = new
osg::GraphicsContext::Traits;
traits-inheritedWindowData = windata;
//.. all the other traits setting here
osg::ref_ptrosgViewer::GraphicsWindowWin32 window = new
osgViewer::GraphicsWindowWin32(traits);
m_gw = window;
window-realize();
osg::GraphicsContext* gc = window;
m_viewer-getCamera()-setGraphicsContext(gc);
Cheers,
Brad
-Original Message-
From: osg-users-boun...@lists.openscenegraph.org
[mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of
Christiansen, Brad
Sent: Thursday, 21 January 2010 9:30 AM
To: OpenSceneGraph Users
Subject: [osg-users] Changing the window of a Viewer
Hi,
I have setup a viewer using an existing window (supplying the HWND to a
GraphicsWindowWin32). In my application, this window can be toggled on
and off. If I do nothing when this happens the GraphicsWindowWin32
complains of an invalid handle when swapping buffers.
As such, I wish to recreate the context when the window is displayed. I
have tried simply calling close on the on the old GraphicsWindowWin32
and then creating a new instance with the new window handle and setting
this on the viewer (osgViewer::Viewer). When I do this, sometimes my
model displays with corrupt textures, but in all cases I get a 'GL is
out of memory' error. I am guessing that I am not cleaning up the old
context and its associated Texture Objects etc correctly.
My question is, what is the correct way of doing this? What methods do I
need to call to clean up all the old GL objects and make sure new ones
are created? Also, do I need to call these methods while the windows
handle is still valid, and do I need to do this on the rendering thread.
Cheers,
Brad
DISCLAIMER:-
--
This e-mail transmission and any documents, files and previous e-mail
messages
attached to it are private and confidential. They may contain
proprietary or copyright
material or information that is subject to legal professional privilege.
They are for
the use of the intended recipient only. Any unauthorised viewing, use,
disclosure,
copying, alteration, storage or distribution of, or reliance on, this
message is
strictly prohibited. No part may be reproduced, adapted or transmitted
without the
written permission of the owner. If you have received this transmission
in error, or
are not an authorised recipient, please immediately notify the sender by
return email,
delete this message and all copies from your e-mail system, and destroy
any printed
copies. Receipt by anyone other than the intended recipient should not
be deemed a
waiver of any privilege or protection. Thales Australia does not warrant
or represent
that this e-mail or any documents, files and previous e-mail messages
attached are
error or virus free.
--
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.or
g
DISCLAIMER:---
This e-mail transmission and any documents, files and previous e-mail messages
attached to it are private and confidential. They may contain proprietary or
copyright
material or information that is subject to legal professional privilege. They
are for
the use of the intended recipient only. Any unauthorised viewing, use,
disclosure,
copying, alteration, storage or distribution of, or reliance on, this message
is
strictly prohibited. No part may be reproduced, adapted or transmitted
without the
written permission of the owner. If you have received this transmission in
error, or
are not an authorised recipient, please immediately notify the sender by
return email,
delete this message and all copies from your e-mail system, and destroy any
printed
copies. Receipt by anyone other than the intended recipient should not be
deemed a
waiver of any privilege or protection. Thales Australia does not warrant or
represent
that this e-mail or any documents