osg OpenSceneGraph Could not find plugin to read objects from file “xxxx“.) Error writing

osg系列文章目录

前言

运行VS2019的OSG工程时,前一天可以正常读取模型与纹理windows字体文件,今天就不行了
Error reading file C:\Windows\Fonts\arial.ttf: read error (Could not find plugin to read objects from file “C:\Windows\Fonts\arial.ttf”.)
Error writing file Text.osg: write error (Could not find plugin to write nodes to file “Text.osg”.)
Failed in osgDB::writeNodeFile().
Successfully wrote “Text.osg”. Execute " osgviewer Text.osg" to view.
void StateSet::setGlobalDefaults() ShaderPipeline disabled.
Error reading file Text.osg: read error (Could not find plugin to read objects from file “Text.osg”.)
请按任意键继续. . .

在这里插入图片描述

一、问题定位

首先,从编译器的错误提示来看,osg的读写字体文件的插件dll找不到了。因为我把osg相关的环境变量全部删除了,我的机器上安装了多个osg版本,把这些不同版本的osg写入环境变量是会冲突的。所以程序找不到对应的osg读写文件插件而报错

二、解决

1.修改系统环境变量

在系统环境变量中只保留一个版本的osg 的path路径,运行的工程用到哪个版本的osg,就在环境变量中设置哪个osg 的path路径。缺点是,反复修改环境变量,而且还要重启机器,太麻烦。也可以不用重启,注销一下系统环境变量就会生效。
在这里插入图片描述

2.在每个osg工程中配置osg头文件lib和dll已经plugins

删除掉环境变量中osg相关的路径,在每个osg工程中都包含osg头文件lib和dll已经plugins
在这里插入图片描述

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值