From Mario Valle,
osgviewerWX: "To make the example compile using a wx build non UNICODE based. Tested on Linux with wxGTK 2.8.4" osgviewerFOX: "Added removeChore() call in the FOX_OSG_MDIView destructor to get rid of a Trace/BPT trap error on exit on Linux. BTW this is suggested also in the FOX documentation."
This commit is contained in:
parent
9a73a3f461
commit
607f92e1fa
@ -9,64 +9,65 @@
|
||||
|
||||
// Map
|
||||
FXDEFMAP(FOX_OSG_MDIView) FOX_OSG_MDIView_Map[] = {
|
||||
//________Message_Type_________ ___ID___ ________Message_Handler________
|
||||
FXMAPFUNC(SEL_CHORE, FOX_OSG_MDIView::ID_CHORE, FOX_OSG_MDIView::OnIdle)
|
||||
//________Message_Type_________ ___ID___ ________Message_Handler________
|
||||
FXMAPFUNC(SEL_CHORE, FOX_OSG_MDIView::ID_CHORE, FOX_OSG_MDIView::OnIdle)
|
||||
};
|
||||
|
||||
FXIMPLEMENT(FOX_OSG_MDIView, FXMDIChild, FOX_OSG_MDIView_Map, ARRAYNUMBER(FOX_OSG_MDIView_Map))
|
||||
|
||||
FOX_OSG_MDIView::FOX_OSG_MDIView(FXMDIClient *p, const FXString &name,
|
||||
FXIcon *ic, FXPopup *pup, FXuint opt,
|
||||
FXint x, FXint y, FXint w, FXint h)
|
||||
: FXMDIChild(p, name, ic, pup, opt, x, y, w, h)
|
||||
FXIcon *ic, FXPopup *pup, FXuint opt,
|
||||
FXint x, FXint y, FXint w, FXint h)
|
||||
: FXMDIChild(p, name, ic, pup, opt, x, y, w, h)
|
||||
{
|
||||
// A visual to drag OpenGL in double-buffered mode; note the glvisual is
|
||||
// shared between all windows which need the same depths and numbers of buffers
|
||||
// Thus, while the first visual may take some time to initialize, each subsequent
|
||||
// window can be created very quickly; we need to determine grpaphics hardware
|
||||
// characteristics only once.
|
||||
FXGLVisual* glVisual=new FXGLVisual(getApp(),VISUAL_DOUBLEBUFFER|VISUAL_STEREO);
|
||||
// A visual to drag OpenGL in double-buffered mode; note the glvisual is
|
||||
// shared between all windows which need the same depths and numbers of buffers
|
||||
// Thus, while the first visual may take some time to initialize, each subsequent
|
||||
// window can be created very quickly; we need to determine grpaphics hardware
|
||||
// characteristics only once.
|
||||
FXGLVisual* glVisual=new FXGLVisual(getApp(),VISUAL_DOUBLEBUFFER|VISUAL_STEREO);
|
||||
|
||||
m_gwFox = new GraphicsWindowFOX(this, glVisual, NULL, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y, x, y, w, h );
|
||||
m_gwFox = new GraphicsWindowFOX(this, glVisual, NULL, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y, x, y, w, h );
|
||||
|
||||
osgViewer::Viewer *viewer = new osgViewer::Viewer;
|
||||
viewer->getCamera()->setGraphicsContext(m_gwFox);
|
||||
viewer->getCamera()->setViewport(0,0,w,h);
|
||||
viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);
|
||||
osgViewer::Viewer *viewer = new osgViewer::Viewer;
|
||||
viewer->getCamera()->setGraphicsContext(m_gwFox);
|
||||
viewer->getCamera()->setViewport(0,0,w,h);
|
||||
viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);
|
||||
|
||||
// load the scene.
|
||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile("cow.osg");
|
||||
if (!loadedModel)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
// load the scene.
|
||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile("cow.osg");
|
||||
if (!loadedModel)
|
||||
{
|
||||
return ;
|
||||
}
|
||||
|
||||
// add the stats handler
|
||||
// add the stats handler
|
||||
viewer->addEventHandler(new osgViewer::StatsHandler);
|
||||
|
||||
viewer->setSceneData(loadedModel.get());
|
||||
viewer->setSceneData(loadedModel.get());
|
||||
|
||||
viewer->setCameraManipulator(new osgGA::TrackballManipulator);
|
||||
viewer->setCameraManipulator(new osgGA::TrackballManipulator);
|
||||
|
||||
SetViewer(viewer);
|
||||
SetViewer(viewer);
|
||||
|
||||
getApp()->addChore(this,ID_CHORE);
|
||||
getApp()->addChore(this,ID_CHORE);
|
||||
|
||||
}
|
||||
|
||||
|
||||
FOX_OSG_MDIView::~FOX_OSG_MDIView()
|
||||
{
|
||||
getApp()->removeChore(this,ID_CHORE);
|
||||
}
|
||||
|
||||
long FOX_OSG_MDIView::OnIdle(FXObject *sender, FXSelector sel, void* ptr)
|
||||
{
|
||||
m_osgViewer->frame();
|
||||
getApp()->addChore(this, ID_CHORE);
|
||||
return 1;
|
||||
m_osgViewer->frame();
|
||||
getApp()->addChore(this, ID_CHORE);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void FOX_OSG_MDIView::SetViewer(osgViewer::Viewer* viewer)
|
||||
{
|
||||
m_osgViewer = viewer;
|
||||
m_osgViewer = viewer;
|
||||
}
|
||||
|
@ -27,28 +27,28 @@ bool wxOsgApp::OnInit()
|
||||
|
||||
// create osg canvas
|
||||
// - initialize
|
||||
|
||||
|
||||
|
||||
int width = 800;
|
||||
int height = 600;
|
||||
|
||||
GraphicsWindowWX* gw = new GraphicsWindowWX(frame, wxID_ANY, wxDefaultPosition,
|
||||
wxSize(width, height), wxSUNKEN_BORDER);
|
||||
|
||||
|
||||
|
||||
|
||||
osgViewer::Viewer *viewer = new osgViewer::Viewer;
|
||||
viewer->getCamera()->setGraphicsContext(gw);
|
||||
viewer->getCamera()->setViewport(0,0,width,height);
|
||||
viewer->addEventHandler(new osgViewer::StatsHandler);
|
||||
viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);
|
||||
|
||||
|
||||
// load the scene.
|
||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile("cow.osg");
|
||||
if (!loadedModel)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
viewer->setSceneData(loadedModel.get());
|
||||
viewer->setCameraManipulator(new osgGA::TrackballManipulator);
|
||||
|
||||
@ -81,7 +81,7 @@ void MainFrame::SetViewer(osgViewer::Viewer *viewer)
|
||||
void MainFrame::OnIdle(wxIdleEvent &event)
|
||||
{
|
||||
_viewer->frame();
|
||||
|
||||
|
||||
event.RequestMore();
|
||||
}
|
||||
|
||||
@ -100,7 +100,7 @@ GraphicsWindowWX::GraphicsWindowWX(wxWindow *parent, wxWindowID id,
|
||||
{
|
||||
// default cursor to standard
|
||||
_oldCursor = *wxSTANDARD_CURSOR;
|
||||
|
||||
|
||||
_traits = new GraphicsContext::Traits;
|
||||
_traits->x = pos.x;
|
||||
_traits->y = pos.y;
|
||||
@ -108,7 +108,7 @@ GraphicsWindowWX::GraphicsWindowWX(wxWindow *parent, wxWindowID id,
|
||||
_traits->height = size.y;
|
||||
|
||||
init();
|
||||
|
||||
|
||||
}
|
||||
|
||||
void GraphicsWindowWX::init()
|
||||
@ -121,7 +121,7 @@ void GraphicsWindowWX::init()
|
||||
if (_traits.valid() && _traits->sharedContext)
|
||||
{
|
||||
getState()->setContextID( _traits->sharedContext->getState()->getContextID() );
|
||||
incrementContextIDUsageCount( getState()->getContextID() );
|
||||
incrementContextIDUsageCount( getState()->getContextID() );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -148,7 +148,7 @@ void GraphicsWindowWX::OnSize(wxSizeEvent& 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.
|
||||
getEventQueue()->windowResize(0, 0, width, height);
|
||||
resized(0,0,width,height);
|
||||
@ -161,12 +161,12 @@ void GraphicsWindowWX::OnEraseBackground(wxEraseEvent& WXUNUSED(event))
|
||||
|
||||
void GraphicsWindowWX::OnKeyDown(wxKeyEvent &event)
|
||||
{
|
||||
#if 1
|
||||
#if wxUSE_UNICODE
|
||||
int key = event.GetUnicodeKey();
|
||||
#else
|
||||
int key = event.GetKeyCode();
|
||||
#endif
|
||||
getEventQueue()->keyPress(key);
|
||||
getEventQueue()->keyPress(key);
|
||||
|
||||
// propagate event
|
||||
event.Skip();
|
||||
@ -174,12 +174,12 @@ void GraphicsWindowWX::OnKeyDown(wxKeyEvent &event)
|
||||
|
||||
void GraphicsWindowWX::OnKeyUp(wxKeyEvent &event)
|
||||
{
|
||||
#if 1
|
||||
#if wxUSE_UNICODE
|
||||
int key = event.GetUnicodeKey();
|
||||
#else
|
||||
int key = event.GetKeyCode();
|
||||
#endif
|
||||
getEventQueue()->keyRelease(key);
|
||||
getEventQueue()->keyRelease(key);
|
||||
|
||||
// propagate event
|
||||
event.Skip();
|
||||
|
Loading…
Reference in New Issue
Block a user