i have some trouble with acces violations and this happend to me more than offen.
some code giving me the latest error.
Code: Select all
bool wxOsgApp::OnInit()
{
// Create the main frame window
MainFrame *frame = new MainFrame(NULL, wxT("wxWidgets OSG Sample"),
wxDefaultPosition, wxDefaultSize);
// create osg canvas
// - initialise
OsgGLCanvas *canvas = new OsgGLCanvas(frame, wxID_ANY, wxDefaultPosition,
wxSize(200, 200), wxSUNKEN_BORDER);
canvas->init("cow.osg");
frame->SetCanvas(canvas);
/* Show the frame */
frame->Show(true);
return true;
}
Code: Select all
bool OsgGLCanvas::init(const std::string &filename)
{
// load the scene.
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile("cow.osg");
if (!loadedModel)
{
return false;
}
// create the view of the scene.
viewer_ = new osgViewer::SimpleViewer;
viewer_->setSceneData(loadedModel.get());
viewer_->setCameraManipulator(new osgGA::TrackballManipulator);
return true;
}
Code: Select all
void OsgGLCanvas::OnSize(wxSizeEvent& event)
{
// this is also necessary to update the context on some platforms
wxGLCanvas::OnSize(event);
// set GL viewport (not called by wxGLCanvas::OnSize on all platforms...)
int width, height;
GetClientSize(&width, &height);
// update the window dimensions, in case the window has been resized.
viewer_->getEventQueue()->windowResize(0, 0, width, height);
}
for making the picture whole viewer_ i declared in the h file
Code: Select all
class OsgGLCanvas: public wxGLCanvas
{
public:
OsgGLCanvas(wxWindow *parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxString& name = wxT("TestGLCanvas"));
~OsgGLCanvas();
bool init(const std::string &filename);
void OnPaint(wxPaintEvent& event);
void OnSize(wxSizeEvent& event);
void OnEraseBackground(wxEraseEvent& event);
void OnMouse(wxMouseEvent &event);
private:
osg::ref_ptr<osgViewer::SimpleViewer> viewer_;
DECLARE_EVENT_TABLE()
};
any help is apriciated.
thnx in advanced
Ewart ten Brink
ps the error message
First-chance exception at 0x00401885 in wxOsgCanvasTest.exe: 0xC0000005: Access violation reading location 0x00000004.
Unhandled exception at 0x00401885 in wxOsgCanvasTest.exe: 0xC0000005: Access violation reading location 0x00000004.