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."
This commit is contained in:
parent
110c761695
commit
670c7967ae
@ -21,17 +21,23 @@
|
||||
// `Main program' equivalent, creating windows and returning main app frame
|
||||
bool wxOsgApp::OnInit()
|
||||
{
|
||||
// Create the main frame window
|
||||
MainFrame *frame = new MainFrame(NULL, wxT("wxWidgets OSG Sample"),
|
||||
wxDefaultPosition, wxDefaultSize);
|
||||
|
||||
// create osg canvas
|
||||
// - initialize
|
||||
|
||||
if (argc<2)
|
||||
{
|
||||
std::cout << wxString(argv[0]).mb_str() <<": requires filename argument." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
int width = 800;
|
||||
int height = 600;
|
||||
|
||||
// Create the main frame window
|
||||
|
||||
MainFrame *frame = new MainFrame(NULL, wxT("wxWidgets OSG Sample"),
|
||||
wxDefaultPosition, wxSize(width, height));
|
||||
|
||||
// create osg canvas
|
||||
// - initialize
|
||||
|
||||
int *attributes = new int[6];
|
||||
attributes[0] = int(WX_GL_DOUBLEBUFFER);
|
||||
attributes[1] = WX_GL_RGBA;
|
||||
@ -42,7 +48,7 @@ bool wxOsgApp::OnInit()
|
||||
|
||||
GraphicsWindowWX* gw = new GraphicsWindowWX(frame, wxID_ANY, wxDefaultPosition,
|
||||
wxSize(width, height), wxSUNKEN_BORDER, wxT("osgviewerWX"), attributes);
|
||||
|
||||
|
||||
osgViewer::Viewer *viewer = new osgViewer::Viewer;
|
||||
viewer->getCamera()->setGraphicsContext(gw);
|
||||
viewer->getCamera()->setViewport(0,0,width,height);
|
||||
@ -50,9 +56,11 @@ bool wxOsgApp::OnInit()
|
||||
viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);
|
||||
|
||||
// load the scene.
|
||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile("cow.osg");
|
||||
wxString fname(argv[1]);
|
||||
osg::ref_ptr<osg::Node> loadedModel = osgDB::readNodeFile(std::string(fname.mb_str()));
|
||||
if (!loadedModel)
|
||||
{
|
||||
std::cout << argv[0] <<": No data loaded." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user