viewer.realize();//需要realize,否则窗口为null
osgViewer::GraphicsWindow *pWnd = dynamic_cast<osgViewer::GraphicsWindow*>(viewer.getCamera()->getGraphicsContext());
if (pWnd) {
pWnd->setWindowRectangle(, , ,); pWnd->setWindowDecoration(true);
}
在main函数中添加,在viewer.run()之前。