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();
}
本文介绍了如何使用OSG库来调整窗口大小、获取显示器分辨率,并添加系统菜单(包括关闭、最小化和最大化按钮)。通过具体代码示例展示了实现这些功能的方法。

789

被折叠的 条评论
为什么被折叠?



