c++ - osg::GraphicsContext::WindowingSystemInterface 返回 null

标签 c++ visual-studio openscenegraph

在我的 OpenSceneGraph 程序中,我有以下代码:

osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();

    if (!wsi) {
        osg::notify(osg::NOTICE) << "Error, no WindowingSystemInterface available, cannot create windows." << std::endl;
        return 0;
    }

不幸的是,方法 getWindowingSystemInterface() 返回了一个空值,因此程序无法继续。它返回 null 的原因是什么?我如何更改我的程序(或build设置?)以让它返回非空值?我正在使用 Visual Studio 2012。

最佳答案

您可能在接口(interface)创建之前就对其进行了查询,因此它返回一个空值。如果您使用控制台窗口运行,请尝试将 OSG_NOTIFY_LEVEL 环境变量设置为 INFO 或 DEBUG,它会准确告诉您是否/何时设置窗口界面。

请参阅“设置”方法(无论如何来自 3.1.3 开发版本),如果您的通知级别为 INFO 或更高,它会执行打印:

void GraphicsContext::setWindowingSystemInterface(WindowingSystemInterface* callback)
{
    ref_ptr<GraphicsContext::WindowingSystemInterface> &wsref = windowingSystemInterfaceRef();
    wsref = callback;
    OSG_INFO<<"GraphicsContext::setWindowingSystemInterface() "<<wsref.get()<<"\t"<<&wsref<<std::endl;
}

http://www.openscenegraph.com/index.php/documentation/debugging-tips

关于c++ - osg::GraphicsContext::WindowingSystemInterface 返回 null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25843405/

相关文章:

android - 如何从 Android NDK 获取资源中的文件

c++ - 在 C++ 中,是否可以直接从另一个数组初始化一个数组?

c++ - 创建链表时使用 new 运算符

c++ - 具有非类型模板参数成员函数的模板类

c# - 无法安装 .NET 框架,因为 Windows 认为安装了更新版本

c++ - 纹理坐标 OSG GLSL

c++ - 大数模幂运算

visual-studio - 如何将 VisualStudio 项目转换为 Eclipse CDT

wpf - MSIX 使用 Azure SSO 的已安装 WPF 应用程序将无法启动

c++ - 如何正确更新几何图形