I dont' find any thing wrong with your code, nor do I find the behaviour you describe normal. When adding a variable that isn't even referenced in code makes a difference between crashing and not, it causes me to think that there is a greater problem going on with memory management. The fact that accessing a string (as in setWindowName()) effects a crash supports this suspicion.
A common error that occurs with Windows users is to have more than one library/header files installed on the system. Could this be the case?
-don
On 11/13/06, Stephen Northcott <[EMAIL PROTECTED]> wrote:
Hi Don,
Thanks for getting back to me so fast..
I kind of moved the problem on to a next stage (kind of)....
Here are the chunks of my main loop that are relevant..
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
First the Viewer SETUP CODE..
(IndieView is just a class which encapsulates pointers to
rendersurface, sceneview, callbacks, etc. for portability between a
few main loops)
void IndieView::main_realize(ui* _person, osg::Group* _root, Pipe*
_pipeline)
{
// create the window to draw to.
this->renderSurface = new Producer::RenderSurface;
this->renderSurface->setWindowName("PipeView Standalone v0.5");
this->renderSurface->setWindowRectangle(100,100,800,700);
this->renderSurface->useBorder(true);
this->renderSurface->realize();
// create the view of the scene.
this->sceneView = new osgViewer::SimpleViewer;
// set up a KeyboardMouse to manage the events comming in from
the RenderSurface
this->kbm = new Producer::KeyboardMouse(this->renderSurface);
// create a KeyboardMouseCallback to handle the mouse events
within this applications
this->kbmcb = new MyKeyboardMouseCallback(this->sceneView-
>getEventQueue());
// create a tracball manipulator to move the camera around in
response to keyboard/mouse events
this->cameraManipulator = new osgGA::TrackballManipulator;
this->statesetManipulator = new osgGA::StateSetManipulator;
statesetManipulator->setStateSet(this->sceneView->getSceneView()-
>getGlobalStateSet());
// add the pick and sateset manipulators
this->sceneView->addEventHandler(statesetManipulator);
this->sceneView->addEventHandler(new PickHandler(this->sceneView));
// set the window dimensions
this->sceneView->getEventQueue()->getCurrentEventState()-
>setWindowRectangle(100,100,800,700);
// set the mouse input range (note WindowSize name in
appropriate here so osgGA::GUIEventAdapter API really needs looking
at, Robert Osfield, June 2006).
// Producer defaults to using non-dimensional units, so we pass
this onto osgGA, most windowing toolkits use pixel coords so use the
window size instead.
this->sceneView->getEventQueue()->getCurrentEventState()-
>setInputRange(-1.0, -1.0, 1.0, 1.0);
// Producer has the y axis increase upwards, like OpenGL, and
contary to most Windowing toolkits.
// we need to construct the event queue so that it knows about
this convention.
this->sceneView->getEventQueue()->getCurrentEventState()-
>setMouseYOrientation(osgGA::GUIEventAdapter::Y_INCREASING_UPWARDS);
this->sceneView->init();
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
Now the main refresh subroutine called in the main loop....
void IndieView::main_chunk2()
{
// update the viewport dimensions, in case the window has
been resized.
this->sceneView->getEventQueue()->windowResize(0,0,renderSurface-
>getWindowWidth(),renderSurface->getWindowHeight(), false);
// pass any keyboard mouse events onto the local keyboard mouse
callback.
this->kbm->update( *kbmcb );
this->sceneView->frame();
// Swap Buffers
this->renderSurface->swapBuffers();
}
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////
Ok... Stuff I have found out so far, and some info about the above..
I found that by simply placing this bogus declaration..
WNDCLASSEX wx;
..before this code when I initialise..
this->renderSurface = new Producer::RenderSurface;
this->renderSurface->setWindowName(" PipeViewStandalonev0.5");
this->renderSurface->setWindowRectangle(100,100,800,700);
this->renderSurface->useBorder(true);
this->renderSurface->realize();
...then Producer does in fact create a window..
However, it will crash unless I comment out the 'setWindowName' command.
That is strange as everything else works, and makes me wonder if I am
still not giving Producer quite what it expects with my bogus
declaration.
Without "WNDCLASSEX wx;", Producer reports back that it 'cannot find
window class'.
The WNDCLASSEX declaration appears to open up the Class that Producer
is looking for, but perhaps not!
Previously I had thought my program was then crashing when I did this
in the main loop..
this->renderSurface->swapBuffers();
.. actually it is crashing in the line before that...
this->sceneView->frame();
The crash is actually a 'vector subscript out of range' error, in
vector.
And drops through to stdthrow.cpp.
If I remove the this->sceneView->frame call then my program loops
fine, but with a Producer window that does not update at all, and
draws no initial scene view, obviously.
The exact same code on OS X is fine. The only difference is I don't
have the WNDCLASSEX wx; declaration in the OS X version.
Ok... You can laugh now! :-)
Kindd regards,
Stephen.
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/
_______________________________________________ osg-users mailing list [email protected] http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
