1.准备文件
VS2015 x64
OSG源码3.4.0 地址:http://www.openscenegraph.org/index.php/download-section/stable-releases
OSG第三方库 地址:http://www.openscenegraph.org/index.php/download-section/dependencies(需要自己编译)
OSG数据包 地址:http://www.openscenegraph.org/index.php/download-section/data
CMake 地址:百度搜索官网下载
2.编译准备
1)编译第三方库:参考https://github.com/bjornblissing/osg-3rdparty-cmake
2)编译源码: 参考https://blog.csdn.net/hsc1239653453/article/details/78278567
注意:选择64位的,原文为32位;;CMAKE_INSTALL_PREFIX为最终工程编译完以后的存放路径。
3.编译工程 参考:https://blog.csdn.net/hsc1239653453/article/details/78278567
注意:要求编译Debug和Release两种dll
4.环境配置
4.1
添加用户变量,值为OSG data的路径
添加系统变量PATH,值为CMAKE_INSTALL_PREFIX(最终工程编译完以后的存放路径)下的bin文件夹
4.2项目环境配置
参考:https://blog.csdn.net/hsc1239653453/article/details/78278567
其中链接器中的依赖库为(配置为Debug)
OpenThreadsd.lib
osgd.lib
osgDBd.lib
osgUtild.lib
osgGAd.lib
osgViewerd.lib
osgTextd.lib
osgFXd.lib
osgManipulatord.lib
osgParticled.lib
osgShadowd.lib
osgSimd.lib
osgTerraind.lib
5.测试(注意#include <Windows.h>的顺序)
#include "stdafx.h"
#include <Windows.h>
#include <osgViewer/Viewer>
#include <osgDB/ReadFile>
int main(int argc, char **argv)
{
osgViewer::Viewer viewer;
viewer.setSceneData(osgDB::readNodeFile("cessna.osg"));
return viewer.run();
}