Unhandled exception when creating view?


When executing the following code I get an unhandled exception when line 12 executes. Am I missing something here? This code is placed inside a class which is derived from a frame.

1 //create a 3D viewer
2 Handle(Graphic3d_WNTGraphicDevice) myGraphicDevice = new Graphic3d_WNTGraphicDevice();
3 TCollection_ExtendedString aName("My App");
4 V3d_Viewer* Viewer = new V3d_Viewer(myGraphicDevice,aName.ToExtString(),"");
5 Viewer->SetDefaultLights();
6 Viewer->SetLightOn();
8 //create a 3D view
9 Handle(WNT_Window) aWNTWindow;
10 aWNTWindow = new WNT_Window(myGraphicDevice, (HWND*)this->GetHandle());
11 Handle(V3d_View) View;
12 View = Viewer->CreateView();
13 View->SetWindow(aWNTWindow);
15 //create an interactive context
16 Handle(AIS_InteractiveContext) myAISContext;
17 myAISContext =new AIS_InteractiveContext(Viewer);
19 //create and display a trihedron in the viewer
20 Handle(AIS_Trihedron) aTrihedron;
21 Handle(Geom_Axis2Placement) anAxis=new Geom_Axis2Placement(gp::XOY());
22 aTrihedron=new AIS_Trihedron(anAxis);
23 myAISContext->Display(aTrihedron);

Kind regards Foxtrot

EricThompson's picture

I'm not sure if this is your problem, but in our code there is a call to:


before our call to Viewer->CreateView();
I have no idea what that does, but you might want to try it.

vliegenkristof's picture

Thanks for the reply, I got it working a few days ago however, the problem was situated in line 4 of the my code snippet:

//Wrong, original code
V3d_Viewer* Viewer = new V3d_Viewer(myGraphicDevice,aName.ToExtString(),"");

//Right, working code
Handle(V3d_View) View = new V3d_Viewer(myGraphicDevice,aName.ToExtString(),"");

Kind regards