[osg-users] Memory not being released, causing crash

2019-05-16 Thread Juan Cruz
Hi,

I have a problem where when I create a OSG scene, then delete it, apparently 
the memory is not being released.  I say this because if I re-open the scene 3 
times, the 3rd time the textures show partially black, and the 4th time I close 
and re-open the scene, the program crashes.  It seems to me it's reaching a 
memory limit.

I'm deleting all children under the root group, setting the viewer scene data 
to null, and deleting everything before re-opening the scene.  What could be 
going on?

Thank you!

Cheers,
Juan

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





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


[osg-users] osgQt & osgEarth not working with 0 margin in Qlayout

2019-05-16 Thread David Bobavid
Hi,

I've come across an issue I'm sort of confused about, and hopefully someone can 
help figure it out. 

I'm using osgQt & osgEarth 2.10 & osg 3.6.3 with Qt 5.12 on Windows 10. It all 
seems to work, and I'm following the osgQt Viewer example for setting up my 
program. My osg widget, when added to my frame, has the default margin and 
spacing, so when I set it to my central widget (in a QMainWidget) it has a gray 
border. However, when I set the margins to 0, it won't draw the map at all, and 
it shows some artifacts around the edge of the widget. 

This is what I'm doing:

Code:

OsgViewerQWidget::OsgViewerQWidget(QWidget* parent /*= 0*/, Qt::WindowFlags f 
/*= 0*/, QStatusBar* statusBar /*= 0*/)
: QWidget(parent, f)
{
 _map = new osgEarth::Map();

// add a TMS imagery layer: 
osgEarth::Drivers::TMSOptions imagery;
imagery.url() = "http://readymap.org/readymap/tiles/1.0.0/7/;;
_map->addLayer(new osgEarth::ImageLayer("ReadyMap Imagery", imagery));

// add a TMS elevation layer:
osgEarth::Drivers::TMSOptions elevation;
elevation.url() = "http://readymap.org/readymap/tiles/1.0.0/116/;;
_map->addLayer(new osgEarth::ElevationLayer("ReadyMap Elevation", elevation));

graticuleLayer = new osgEarth::Util::GeodeticGraticule();
_map->addLayer(graticuleLayer);

// That's it, the map is ready; now create a MapNode to render the Map:
_mapNode = new osgEarth::MapNode(_map);

_mapNode->setNodeMask(0x1);

setThreadingModel(osgViewer::ViewerBase::SingleThreaded);

// disable the default setting of viewer.done() by pressing Escape.
setKeyEventSetsDone(0);

QWidget* widget1 = AddViewWidget(CreateGraphicsWindow(0, 0, 100, 100), 
_mapNode, statusBar);

QGridLayout* grid = new QGridLayout;
setLayout(grid);

grid->setSpacing(0);
//grid->setContentsMargins(0, 0, 0, 0);   // with this line commented out, 
it works, with it in, it doesn't work... but, why?!
grid->addWidget(widget1);

connect(&_timer, SIGNAL(timeout()), this, SLOT(update()));
_timer.start(10);
}

osgQt::GraphicsWindowQt* OsgViewerQWidget::CreateGraphicsWindow(int x, int y, 
int w, int h, const std::string& name /*= ""*/, bool windowDecoration /*= 
false*/)
{
osg::DisplaySettings* ds = osg::DisplaySettings::instance().get();
osg::ref_ptr traits = new 
osg::GraphicsContext::Traits;
traits->windowName = name;
traits->windowDecoration = windowDecoration;
traits->x = x;
traits->y = y;
traits->width = w;
traits->height = h;
traits->doubleBuffer = true;
traits->alpha = ds->getMinimumNumAlphaBits();
traits->stencil = ds->getMinimumNumStencilBits();
traits->sampleBuffers = ds->getMultiSamples();
traits->samples = ds->getNumMultiSamples();

return new osgQt::GraphicsWindowQt(traits.get());
}

QWidget* OsgViewerQWidget::AddViewWidget(osgQt::GraphicsWindowQt* gw, 
osg::ref_ptr scene, QStatusBar *statusBar)
{
osgViewer::View* view = new osgViewer::View;
addView(view);

osg::Camera* camera = view->getCamera();
camera->setGraphicsContext(gw);

// need to do this to make lines show up... o_O  Thanks's Glenn!
osgEarth::Util::GLUtils::setGlobalDefaults(camera->getOrCreateStateSet());

const osg::GraphicsContext::Traits* traits = gw->getTraits();

camera->setClearColor(osg::Vec4(0.2, 0.2, 0.6, 1.0));
camera->setViewport(new osg::Viewport(0, 0, traits->width, traits->height));

// set the draw and read buffers up for a double buffered window with rendering 
going to back buffer
camera->setDrawBuffer(GL_BACK);
camera->setReadBuffer(GL_BACK);

camera->setProjectionMatrixAsPerspective(30.0f, 
static_cast(traits->width) / static_cast(traits->height), 1.0f, 
1.0f);

view->setSceneData(scene);
view->addEventHandler(new osgViewer::StatsHandler);
view->addEventHandler(new 
osgGA::StateSetManipulator(view->getCamera()->getOrCreateStateSet()));
view->addEventHandler(new osgViewer::ThreadingHandler());
view->addEventHandler(new osgViewer::LODScaleHandler());
view->addEventHandler(new osgViewer::ScreenCaptureHandler());

earthManip = new osgEarth::Util::EarthManipulator;
view->setCameraManipulator(earthManip);

ldBuffer = new osgEarth::Util::LogarithmicDepthBuffer;
ldBuffer->install(camera);

gw->setTouchEventsEnabled(true);
return gw->getGLWidget();
}




So it seems to go wrong in my constructor, when I set the grid layout content 
margins to 0. Otherwise this works just fine. I set the margin to 0, and it 
doesn't show anything. 

Any ideas will be greatly appreciated.

Thank you!
David

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





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


Re: [osg-users] Removing objects with shared GL state from scene graph

2019-05-16 Thread Robert Osfield
On Thu, 16 May 2019 at 00:07, Chris Djali  wrote:
> It looks like this has fallen off the radar again as it's been a month. I'd 
> still rather fix this in a robust way rather than making a guess as to the 
> most sensible approach and creating maintenance problems down the line.

Sorry, I've been submerged in VSG work.

Just now I had a quick scan of your test program but haven't compiled
and run it.  My first though is the global World object holds a
ref_ptr<> to the scene graph and there is no mechanism for deleting
this global prior to the viewer cleans up so in essence it's prevent
that scene graph from being deleted and cleaned up.  After the exit of
the main frame loop you could explicitly delete this object.  Another
approach would be to make this World object a custom Group node in the
scene graph that adds the high level behaviors you want and with it
ensure that you can override any releaseGLObjects() etc on any locally
cached objects that would otherwise be hidden from the OSG's attempts
at cleaning things up.

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