HI Jack, What will be happening is viewer.run() method will see that you haven't assigned any graphics windows and realized the viewer so will call viewer.realize() automatically so it's set up properly for rendering. In your case the viewer.realize() will see that you haven't assigned graphics windows so will automatically create a full screen window as a fallback. When creating it's own graphics windows for you it'll reset set the viewport to cover the full window overwriting what you have set yourself.
If you wish to set the viewport to a portion of the window then you could assigned you own graphics window to the viewer's master Camera and set up the viewport accordingly - see osgcamera. If you actually want a small window with a viewport covering the whole window then you could use a convinience method like osgViewer::View::setUpViewInWindow(x,y,width,height). Robert. 2011/11/2 jack big <[email protected]>: > Hi all, > I am a beginner of OSG and just learnt the method of setViewport(). Then I > try to test it in a very simple program which code is like following: > > #include <osg/...> // here includes the nessesary files > > int main( int argc, char** argv ) > { > osg::ref_ptr<osg::Node> model1 = osgDB::readNodeFile("cessna.osg"); > osgViewer::Viewer viewer; > viewer.setSceneData( model1.get() ); > viewer.getCamera()->setViewport(new osg::Viewport(0, 0, 140, 30)); > return viewer.run(); > } > when running the program above I found the line of > "viewer.getCamera()->setViewport(new osg::Viewport(0, 0, 140, 30));" > actually does not work. The model is displayed in the area of the full > screen. Even I tried other values to set the viewport position and size the > result remains the same. Seems the line does not take any effect. Why? > Really wonder about this, can anybody tell me the reason? Thanks a lot! > > Best regards, > Jack > > > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

