LightModel::apply dereferences a pointer when it calls glLightModelfv to set the
ambient scene color. Check under a debugger to see if that's a NULL pointer. If
so, the way to resolve this would be to look at how it gets initialized in the
rest of OSG, then duplicate that in your viewer.
My guess is that LightModel is part of default OSG state, and you're not setting
it up the same way as OSG's viewers. But this is just a guess. You'd need to dig
in the code.
-Paul
Zachary Hilbun wrote:
Hi,
I'm writing a small test program (source below) that is doing its own viewer loop.
This program runs fine if I run it using viewerWindow->show. If I run it with
my own viewer loop it crashes the fist time it calls frame with a Segmentation
fault in osg::LightModel::apply (see stack trace below).
OSG v 2.8.1
Qt 4 (Eclipse integration version 1.6.1) environment
Linux using Eclipse in debug mode
I got ViewerQT from the Qt integration example AdapterWidget.cpp.
I got the viewer loop code from the Quick Start Guide. I noticed some examples had viewerWindow->realize in them so I tried it with and without that. It didn't make any difference.
Any ideas of what the problem is?
ViewerQT *viewerWindow = new ViewerQT;
viewerWindow->setCameraManipulator (new osgGA::TrackballManipulator);
viewerWindow->setSceneData
(osgDB::readNodeFile("/home/zacharyh/OpenSceneGraph-Data-2.8.0/cow.osg"));
// display the scene graph /////////////////////
#define loop
#ifndef loop
viewerWindow->show ();
#else
viewerWindow->getCamera ()->setProjectionMatrixAsPerspective (40., 1., 1., 60.
* 36.);
// Create a matrix to specify a distance from the viewpoint.
osg::Matrix trans;
trans.makeTranslate (0., 0., 0.);
double angle (0.); // Rotation angle (in radians)
viewerWindow->realize (); // crashes with and without this
while ( ! viewerWindow->done ())
{ // do view loop
// Create the rotation matrix.
osg::Matrix rot;
rot.makeRotate (angle, osg::Vec3 (0., 0., 1.));
// angle += 0.01;
// Set the view matrix (the concatenation of the rotation and
// translation matrices).
viewerWindow->getCamera ()->setViewMatrix (rot * trans);
// Draw the next frame.
viewerWindow->frame ();
} // do view loop
#endif
a.connect (&a, SIGNAL (lastWindowClosed ()), &a, SLOT (quit ()));
return a.exec ();
gdb Debugger (6/9/10 10:15 AM) (Suspended)
Thread [1] (Suspended: Signal 'SIGSEGV' received. Description:
Segmentation fault.)
18 osg::LightModel::apply(osg::State&) const() 0x0027778a
17 osg::State::applyAttribute() 0x002d33b0
16 osg::State::applyAttributeList() 0x002d3613
15 osg::State::apply() 0x002ce9b1
14 osgUtil::RenderLeaf::render() 0x016f6b1e
13 osgUtil::RenderBin::drawImplementation() 0x016f0d13
12 osgUtil::RenderStage::drawImplementation() 0x016f93c4
11 osgUtil::RenderBin::draw() 0x016f09a0
10 osgUtil::RenderStage::drawInner() 0x016f9776
9 osgUtil::RenderStage::draw() 0x016fd51d
8 osgUtil::SceneView::draw() 0x017065af
7 osgViewer::Renderer::cull_draw() 0x00480cb0
6 osgViewer::Renderer::operator()() 0x0047e208
5 osg::GraphicsContext::runOperations() 0x0024b928
4 osgViewer::ViewerBase::renderingTraversals() 0x004bfb42
3 osgViewer::ViewerBase::frame() 0x004bd8dd
2 shotTrail()
/home/zacharyh/workspace/osgViewerQt/ShotTrail.cpp:86 0x0805454d
1 main() /home/zacharyh/workspace/osgViewerQt/main.cpp:40
0x0805edf5
Thank you!
Cheers,
Zachary
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=28752#28752
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
--
-Paul Martz Skew Matrix Software
http://www.skew-matrix.com/
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org