• osgearth3.2加载地球


    一、背景

    目前较为常用的osgearth版本分别为2.8,2.10,3.2,其中3.2版本最新,并且3.x版本和2.x版本差别很大,主要区别在于2.x有7个主要库,而3.x版本只有osgEarth这一个库。至于为什么2.x版本还有很多人用,因为2.x和3.x很多函数有了大幅变化,如果升级最新版本的话,代码不兼容,需要改动的地方很多,但实际功能没有明显区别。

    二、代码

    1. #include
    2. #include
    3. #include
    4. #include
    5. #include
    6. #include
    7. #ifdef _DEBUG
    8. //osg库一共19个
    9. #pragma comment(lib, "osgd.lib")
    10. #pragma comment(lib, "osgDBd.lib")
    11. #pragma comment(lib, "osgFXd.lib")
    12. #pragma comment(lib, "osgViewerd.lib")
    13. #pragma comment(lib, "osgVolumed.lib")
    14. #pragma comment(lib, "OpenThreadsd.lib")
    15. #pragma comment(lib, "osgGAd.lib")
    16. #pragma comment(lib, "osgUtild.lib")
    17. #pragma comment(lib, "osgManipulatord.lib")
    18. #pragma comment(lib, "osgTextd.lib")
    19. #pragma comment(lib, "osgSimd.lib")
    20. #pragma comment(lib, "osgTerraind.lib")
    21. #pragma comment(lib, "osgWidgetd.lib")
    22. #pragma comment(lib, "osgUId.lib")
    23. #pragma comment(lib, "osgShadowd.lib")
    24. #pragma comment(lib, "osgAnimationd.lib")
    25. #pragma comment(lib, "osgParticled.lib")
    26. #pragma comment(lib, "osgPresentationd.lib")
    27. #pragma comment(lib, "osgQOpenGLd.lib")
    28. //osgearth库1个
    29. #pragma comment(lib, "osgEarthd.lib")
    30. //其他库2个
    31. #pragma comment(lib, "glu32.lib")
    32. #pragma comment(lib, "opengl32.lib")
    33. #else
    34. #pragma comment(lib, "osg.lib")
    35. #pragma comment(lib, "osgDB.lib")
    36. #pragma comment(lib, "osgFX.lib")
    37. #pragma comment(lib, "osgViewer.lib")
    38. #pragma comment(lib, "osgVolume.lib")
    39. #pragma comment(lib, "OpenThreads.lib")
    40. #pragma comment(lib, "osgGA.lib")
    41. #pragma comment(lib, "osgUtil.lib")
    42. #pragma comment(lib, "osgManipulator.lib")
    43. #pragma comment(lib, "osgText.lib")
    44. #pragma comment(lib, "osgSim.lib")
    45. #pragma comment(lib, "osgTerrain.lib")
    46. #pragma comment(lib, "osgWidget.lib")
    47. #pragma comment(lib, "osgUI.lib")
    48. #pragma comment(lib, "osgShadow.lib")
    49. #pragma comment(lib, "osgAnimation.lib")
    50. #pragma comment(lib, "osgParticle.lib")
    51. #pragma comment(lib, "osgPresentation.lib")
    52. #pragma comment(lib, "osgQOpenGL.lib")
    53. #pragma comment(lib, "osgEarth.lib")
    54. #pragma comment(lib, "glu32.lib")
    55. #pragma comment(lib, "opengl32.lib")
    56. #endif;
    57. int main(int argc, char** argv)
    58. {
    59. osgEarth::initialize();
    60. osgViewer::Viewer *viewer=new osgViewer::Viewer;
    61. //添加状态事件,可以相应键盘和鼠标事件,响应L T B W
    62. viewer->addEventHandler(new osgGA::StateSetManipulator(viewer->getCamera()->getOrCreateStateSet()));
    63. //窗口大小变化,响应F
    64. viewer->addEventHandler(new osgViewer::WindowSizeHandler);
    65. //添加路径记录 Z
    66. viewer->addEventHandler(new osgViewer::RecordCameraPathHandler);
    67. //帮助文档显示H
    68. viewer->addEventHandler(new osgViewer::HelpHandler);
    69. //截屏 C
    70. viewer->addEventHandler(new osgViewer::ScreenCaptureHandler);
    71. //添加一些常用状态设置,响应S
    72. viewer->addEventHandler(new osgViewer::StatsHandler);
    73. viewer->setCameraManipulator(new osgEarth::Util::EarthManipulator);
    74. osg::Group* root = new osg::Group;
    75. root->addChild(osgDB::readNodeFile("simple.earth"));
    76. viewer->setSceneData(root);
    77. return viewer->run();
    78. }

    三、库下载

    链接:https://pan.baidu.com/s/1VMDbP8UeufZ63jTRPKzp-w?pwd=8888 
    提取码:8888 

    vs2017osg3.6.5osgearth3.2库,包含osgQOpenGL库-C++文档类资源-CSDN下载

  • 相关阅读:
    python学习、开发实用文档分享
    使用近场探头和电流探头进行EMI干扰排查
    学习Nano编辑器:入门指南、安装步骤、基本操作和高级功能
    C语言《超详细解析内存函数》
    M的编程备忘录之C++——入门
    开放之光——湖北电大搜题助力学习之旅
    调试接口小技巧-通过接口调试工具去下载上传文件
    基于强化学习的测试日志智能分析实践
    java string.split(“,“)方法的坑
    疾病预防控制中心实验室信息管理系统智慧疾控参数需求
  • 原文地址:https://blog.csdn.net/ljjjjjjjjjjj/article/details/126684701