osg窗口大小调整、获取显示器分辨率、添加系统菜单(关闭、最小化、最大化按钮)
int main(){
osgViewer::Viewer viewer;
viewer.realize(); // 初始化cam->getGraphicsContext()返回的对象
// 获取显示器的信息:分辨率
GraphicsContext::WindowingSystemInterface *wsi = GraphicsContext::getWindowingSystemInterface();
GraphicsContext::ScreenSettings ss;
wsi->getScreenSettings(GraphicsContext::ScreenIdentifier(0), ss);
int width(ss.width), height(ss.height);
// 设置窗口大小
Camera *cam = viewer.getCamera();
osgViewer::GraphicsWindow *gw = dynamic_cast<osgViewer::GraphicsWindow*>(cam->getGraphicsContext());
gw->setWindowRectangle(0, 0, width / 2, height / 2);
gw->setWindowDecoration(true); // 添加程序的关闭、最大化、最小化菜单
return viewer.run();
}