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
|
// `Main program' equivalent, creating windows and returning main app frame
|
||||||
bool wxOsgApp::OnInit()
|
bool wxOsgApp::OnInit()
|
||||||
{
|
{
|
||||||
// Create the main frame window
|
if (argc<2)
|
||||||
MainFrame *frame = new MainFrame(NULL, wxT("wxWidgets OSG Sample"),
|
{
|
||||||
wxDefaultPosition, wxDefaultSize);
|
std::cout << wxString(argv[0]).mb_str() <<": requires filename argument." << std::endl;
|
||||||
|
return false;
|
||||||
// create osg canvas
|
}
|
||||||
// - initialize
|
|
||||||
|
|
||||||
|
|
||||||
int width = 800;
|
int width = 800;
|
||||||
int height = 600;
|
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];
|
int *attributes = new int[6];
|
||||||
attributes[0] = int(WX_GL_DOUBLEBUFFER);
|
attributes[0] = int(WX_GL_DOUBLEBUFFER);
|
||||||
attributes[1] = WX_GL_RGBA;
|
attributes[1] = WX_GL_RGBA;
|
||||||
@ -50,9 +56,11 @@ bool wxOsgApp::OnInit()
|
|||||||
viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);
|
viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);
|
||||||
|
|
||||||
// load the scene.
|
// 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)
|
if (!loadedModel)
|
||||||
{
|
{
|
||||||
|
std::cout << argv[0] <<": No data loaded." << std::endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user