- Timestamp:
- 06/08/07 11:45:11 (6 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/examples/osgviewerGLUT/osgviewerGLUT.cpp
r6864 r6899 20 20 21 21 osg::ref_ptr<osgViewer::Viewer> viewer; 22 osg:: ref_ptr<osgViewer::GraphicsWindow> window;22 osg::observer_ptr<osgViewer::GraphicsWindow> window; 23 23 24 24 void display(void) 25 25 { 26 26 // update and render the scene graph 27 viewer->frame();27 if (viewer.valid()) viewer->frame(); 28 28 29 29 // Swap Buffers … … 35 35 { 36 36 // update the window dimensions, in case the window has been resized. 37 window->resized(window->getTraits()->x, window->getTraits()->y, w, h); 38 window->getEventQueue()->windowResize(window->getTraits()->x, window->getTraits()->y, w, h ); 37 if (window.valid()) 38 { 39 window->resized(window->getTraits()->x, window->getTraits()->y, w, h); 40 window->getEventQueue()->windowResize(window->getTraits()->x, window->getTraits()->y, w, h ); 41 } 39 42 } 40 43 41 44 void mousebutton( int button, int state, int x, int y ) 42 45 { 43 if (state==0) window->getEventQueue()->mouseButtonPress( x, y, button+1 ); 44 else window->getEventQueue()->mouseButtonRelease( x, y, button+1 ); 46 if (window.valid()) 47 { 48 if (state==0) window->getEventQueue()->mouseButtonPress( x, y, button+1 ); 49 else window->getEventQueue()->mouseButtonRelease( x, y, button+1 ); 50 } 45 51 } 46 52 47 53 void mousemove( int x, int y ) 48 54 { 49 window->getEventQueue()->mouseMotion( x, y ); 55 if (window.valid()) 56 { 57 window->getEventQueue()->mouseMotion( x, y ); 58 } 50 59 } 51 60 … … 55 64 { 56 65 case 27: 66 // clean up the viewer 67 if (viewer.valid()) viewer = 0; 57 68 glutDestroyWindow(glutGetWindow()); 58 69 break; 59 70 default: 60 window->getEventQueue()->keyPress( (osgGA::GUIEventAdapter::KeySymbol) key ); 61 window->getEventQueue()->keyRelease( (osgGA::GUIEventAdapter::KeySymbol) key ); 71 if (window.valid()) 72 { 73 window->getEventQueue()->keyPress( (osgGA::GUIEventAdapter::KeySymbol) key ); 74 window->getEventQueue()->keyRelease( (osgGA::GUIEventAdapter::KeySymbol) key ); 75 } 62 76 break; 63 77 }
