Show
Ignore:
Timestamp:
03/13/08 17:22:07 (7 years ago)
Author:
robert
Message:

From Paul Melis, "Here is an updated osgviewerWX example to bring it more in line with the
other GUI toolkit examples. It now takes a model file as command-line
argument (complaining if there isn't one), and its startup window size
is now actually applied (it used to be too small). I tested this with a
unicode-build of wxWidgets, as that is the recommended build type on
Linux with GTK. I'm pretty sure this version of the example will work
for the ANSI build as well, but I have no way of testing."

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/examples/osgviewerWX/osgviewerWX.cpp

    r7307 r7938  
    2222bool wxOsgApp::OnInit() 
    2323{ 
     24    if (argc<2) 
     25    { 
     26        std::cout << wxString(argv[0]).mb_str() <<": requires filename argument." << std::endl; 
     27        return false; 
     28    } 
     29 
     30    int width = 800; 
     31    int height = 600; 
     32 
    2433    // Create the main frame window 
     34 
    2535    MainFrame *frame = new MainFrame(NULL, wxT("wxWidgets OSG Sample"), 
    26         wxDefaultPosition, wxDefaultSize); 
     36        wxDefaultPosition, wxSize(width, height)); 
    2737 
    2838    // create osg canvas 
    2939    //    - initialize 
    30      
    31  
    32     int width = 800; 
    33     int height = 600; 
    3440 
    3541    int *attributes = new int[6]; 
     
    4349    GraphicsWindowWX* gw = new GraphicsWindowWX(frame, wxID_ANY, wxDefaultPosition, 
    4450                                                wxSize(width, height), wxSUNKEN_BORDER, wxT("osgviewerWX"), attributes); 
    45      
     51 
    4652    osgViewer::Viewer *viewer = new osgViewer::Viewer; 
    4753    viewer->getCamera()->setGraphicsContext(gw); 
     
    5157 
    5258    // load the scene. 
    53     osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile("cow.osg"); 
     59    wxString fname(argv[1]); 
     60    osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile(std::string(fname.mb_str())); 
    5461    if (!loadedModel) 
    5562    { 
     63        std::cout << argv[0] <<": No data loaded." << std::endl; 
    5664        return false; 
    5765    }