天天看點

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

osg系列文章目錄

文章目錄

  • ​​osg系列文章目錄​​
  • ​​前言​​
  • ​​一、問題定位​​
  • ​​二、解決​​
  • ​​1.修改系統環境變量​​
  • ​​2.在每個osg工程中配置osg頭檔案lib和dll已經plugins​​

前言

運作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 OpenSceneGraph Could not find plugin to read objects from file “xxxx“.) Error writing

一、問題定位

首先,從編譯器的錯誤提示來看,osg的讀寫字型檔案的插件dll找不到了。因為我把osg相關的環境變量全部删除了,我的機器上安裝了多個osg版本,把這些不同版本的osg寫入環境變量是會沖突的。是以程式找不到對應的osg讀寫檔案插件而報錯

二、解決

1.修改系統環境變量

在系統環境變量中隻保留一個版本的osg 的path路徑,運作的工程用到哪個版本的osg,就在環境變量中設定哪個osg 的path路徑。缺點是,反複修改環境變量,而且還要重新開機機器,太麻煩。也可以不用重新開機,登出一下系統環境變量就會生效。

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

2.在每個osg工程中配置osg頭檔案lib和dll已經plugins

删除掉環境變量中osg相關的路徑,在每個osg工程中都包含osg頭檔案lib和dll已經plugins