# osgtest **Repository Path**: agi_2/osgtest ## Basic Information - **Project Name**: osgtest - **Description**: OpenSceneGraph(OSG)示例程序 - **Primary Language**: Unknown - **License**: LGPL-2.1 - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-01-12 - **Last Updated**: 2026-01-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README [![Build Status](https://travis-ci.org/openscenegraph/OpenSceneGraph.svg?branch=master)](https://travis-ci.org/openscenegraph/OpenSceneGraph) [![Coverity Status](https://scan.coverity.com/projects/9159/badge.svg)](https://scan.coverity.com/projects/openscenegraph-openscenegraph) [![Documentation](https://codedocs.xyz/openscenegraph/OpenSceneGraph.svg)](https://codedocs.xyz/openscenegraph/OpenSceneGraph/) [ABI Tracker](https://abi-laboratory.pro/tracker/timeline/openscenegraph/ "ABI Tracker") # Introduction Welcome to the OpenSceneGraph (OSG). For up-to-date information on the project, in-depth details on how to compile and run libraries and examples, see the documentation on the OpenSceneGraph website: http://www.openscenegraph.org/index.php/documentation For support subscribe to our public mailing list or forum, details at: http://www.openscenegraph.org/index.php/support For the impatient, we've included quick build instructions below, these are are broken down is three parts: 1) General notes on building the OpenSceneGraph 2) macOS release notes 3) iOS release notes If details below are not sufficient then head over to the openscenegraph.org to the Documentation/GettingStarted and Documentation/PlatformSpecifics sections for more indepth instructions. Robert Osfield. Project Lead. 31th January 2020. --- ## Section 1. How to build OpenSceneGraph If you are using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager you can download and install OpenSceneGraph from source with CMake integration using a single command: ``` vcpkg install osg ``` The OpenSceneGraph uses the CMake build system to generate a platform-specific build environment. CMake reads the `CMakeLists.txt` files that you'll find throughout the OpenSceneGraph directories, checks for installed dependencies and then generates files for the selected build system. If you don't already have CMake installed on your system you can grab it from http://www.cmake.org, use version 2.8.0 or later. Details on the OpenSceneGraph's CMake build can be found at: http://www.openscenegraph.org/projects/osg/wiki/Build/CMake Under Unix-like systems (i.e. Linux, IRIX, Solaris, Free-BSD, HP-UX, AIX, macOS) use the `cmake` or `ccmake` command-line utils. Note that `cmake .` defaults to building Release to ensure that you get the best performance from your final libraries/applications. cd OpenSceneGraph cmake . make sudo make install Alternatively, you can create an out-of-source build directory and run cmake or ccmake from there. The advantage to this approach is that the temporary files created by CMake won't clutter the OpenSceneGraph source directory, and also makes it possible to have multiple independent build targets by creating multiple build directories. In a directory alongside the OpenSceneGraph use: mkdir build cd build cmake ../OpenSceneGraph make sudo make install Under Windows use the GUI tool CMakeSetup to build your VisualStudio files. The following page on our wiki dedicated to the CMake build system should help guide you through the process: http://www.openscenegraph.org/index.php/documentation/platform-specifics/windows Under macOS you can either use the CMake build system above, or use the Xcode projects that you will find in the OpenSceneGraph/Xcode directory. See release notes on macOS CMake build below. For further details on compilation, installation and platform-specific information read "Getting Started" guide: http://www.openscenegraph.org/index.php/documentation/10-getting-started ## Section 2. Release notes on macOS build, by Eric Sokolowski et al. There are two ways to compile OpenSceneGraph under macOS. The recommended way is to use CMake to generate Xcode project files and then use Xcode to build the library. The default project will be able to build Debug or Release libraries, examples, and sample applications. The alternative is to build OpenSceneGraph from the command line using `make` or `ninja` using the instructions for Unix-like systems above. Here are some key settings to consider when using CMake: - BUILD_OSG_EXAMPLES - By default this is turned off. Turn this setting on to compile many great example programs. - CMAKE_OSX_ARCHITECTURES - Xcode can create applications, executables, libraries, and frameworks that can be run on more than one architecture. Use this setting to indicate the architectures on which to build OSG. x86_64 is the only supported value for OS versions > 10.7. - OSG_BUILD_APPLICATION_BUNDLES - Normally only executable binaries are created for the examples and sample applications. Turn this option on if you want to create real macOS .app bundles. There are caveats to creating `.app` bundles, see below. - OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX - By default macOS uses the `imageio` plugin instead of the plugins for the individual file types (e.g. `jpg`, `gif`, etc.) to load image file types. The `imageio` plugin can handle all popular file formats through the ImageIO framework. - OSG_WINDOWING_SYSTEM - You have the choice to use Cocoa, Carbon, or X11 when building applications on macOS. Cocoa is the default for OS versions >= 10.5. Carbon and X11 are no longer actively supported, either by Apple or the OSG community. ### APPLICATION BUNDLES (.app bundles) The example programs when built as application bundles only contain the executable file. They do not contain the dependent libraries as would a normal bundle, so they are not generally portable to other machines. They also do not know where to find plugins. An environmental variable OSG_LIBRARY_PATH may be set to point to the location where the plugin .so files are located. OSG_FILE_PATH may be set to point to the location where data files are located. Setting OSG_FILE_PATH to the OpenSceneGraph-Data directory is very useful when testing OSG by running the example programs. Many of the example programs use command-line arguments. When double-clicking on an application (or using the equivalent "open" command on the command line) only those examples and applications that do not require command-line arguments will successfully run. The executable file within the .app bundle can be run from the command-line if command-line arguments are needed. ## Section 3. Release notes on iOS build, by Thomas Hogarth With CMake 3.11, XCode 9.4 and the iOS sdk 11.4 installed you can generate an iOS XCode project using the following command line: export THIRDPARTY_PATH=/path/to/3rdParty cmake ./ -G Xcode -DOSG_BUILD_PLATFORM_IPHONE:BOOL=ON \ -DIPHONE_SDKVER="11.4" \ -DIPHONE_VERSION_MIN="10.0" \ -DOPENGL_PROFILE:STRING=GLES3 \ -DOSG_CPP_EXCEPTIONS_AVAILABLE:BOOL=ON \ -DBUILD_OSG_APPLICATIONS:BOOL=OFF \ -DBUILD_OSG_EXAMPLES:BOOL=ON \ -DOSG_WINDOWING_SYSTEM:STRING=IOS \ -DOSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX="imageio" \ -DDYNAMIC_OPENSCENEGRAPH:BOOL=OFF \ -DDYNAMIC_OPENTHREADS:BOOL=OFF \ -DCURL_INCLUDE_DIR:PATH="$THIRDPARTY_PATH/curl-ios-device/include" \ -DCURL_LIBRARY:PATH="$THIRDPARTY_PATH/curl-ios-device/lib/libcurl.a" \ -DFREETYPE_INCLUDE_DIR_freetype2:PATH="$THIRDPARTY_PATH/freetype-ios-universal/include/freetype" \ -DFREETYPE_INCLUDE_DIR_ft2build:PATH="$THIRDPARTY_PATH/freetype-ios-universal/include" \ -DFREETYPE_LIBRARY:PATH="$THIRDPARTY_PATH/freetype-ios-universal/lib/libFreetype2.a" \ -DTIFF_INCLUDE_DIR:PATH="$THIRDPARTY_PATH/tiff-ios-device/include" \ -DTIFF_LIBRARY:PATH="$THIRDPARTY_PATH/tiff-ios-device/lib/libtiff.a" \ -DGDAL_INCLUDE_DIR:PATH="$THIRDPARTY_PATH/gdal-ios-device/include" \ -DGDAL_LIBRARY:PATH="$THIRDPARTY_PATH/gdal-ios-device/lib/libgdal.a" Be sure to set the THIRDPARTY_PATH to the path containing your thirdparty dependencies. Set IPHONE_SDKVER to the version of the iOS sdk you have installed, in this instance 11.4. IPHONE_VERSION_MIN controls the deployment sdk used by xcode, and lastly set OPENGL_PROFILE to the version of GLES you want to use. Once this completes an XCode project will have been generated in the osg root folder. Open the generated Xcode project, select the example_osgViewerIPhone target. In 'General' tab set a development team. Once this is done you should be able to build and deploy the `example_osgViewerIPhone` target on your device. # OpenSceneGraph 项目构建说明 [![构建状态](https://travis-ci.org/openscenegraph/OpenSceneGraph.svg?branch=master)](https://travis-ci.org/openscenegraph/OpenSceneGraph) [![Coverity 扫描状态](https://scan.coverity.com/projects/9159/badge.svg)](https://scan.coverity.com/projects/openscenegraph-openscenegraph) [![文档](https://codedocs.xyz/openscenegraph/OpenSceneGraph.svg)](https://codedocs.xyz/openscenegraph/OpenSceneGraph/) [ABI 跟踪器](https://abi-laboratory.pro/tracker/timeline/openscenegraph/ "ABI 跟踪器") ## 简介 欢迎使用 OpenSceneGraph(简称 OSG)。 如需获取项目的最新信息,以及编译、运行库文件和示例程序的详细说明,请查阅 OpenSceneGraph 官网的文档: http://www.openscenegraph.org/index.php/documentation 如需技术支持,可订阅我们的公共邮件列表或论坛,详情请见: http://www.openscenegraph.org/index.php/support 为方便心急的用户,我们在下方提供了快速构建说明,主要分为三个部分: 1. 构建 OpenSceneGraph 的通用注意事项 2. macOS 系统下的构建说明 3. iOS 系统下的构建说明 如果以下内容不足以满足你的需求,请访问 openscenegraph.org 官网,查看**文档/快速入门**和**文档/平台专属指南**板块,获取更详尽的构建步骤。 **罗伯特·奥斯菲尔德** 项目负责人 2020 年 1 月 31 日 --- ## 第一部分:如何构建 OpenSceneGraph 如果你使用 [vcpkg](https://github.com/Microsoft/vcpkg/) 依赖管理器,只需执行一条命令,即可从源码下载并安装 OpenSceneGraph,同时集成 CMake 构建工具: ``` vcpkg install osg ``` OpenSceneGraph 采用 CMake 构建系统来生成适用于不同平台的构建环境。CMake 会读取分布在 OpenSceneGraph 各目录下的 `CMakeLists.txt` 文件,检查已安装的依赖项,然后为你选定的构建系统生成对应的配置文件。 如果你的系统尚未安装 CMake,可从 http://www.cmake.org 下载,建议使用 2.8.0 及以上版本。关于 OpenSceneGraph 的 CMake 构建流程,可参考以下链接: http://www.openscenegraph.org/projects/osg/wiki/Build/CMake 在类 Unix 系统中(如 Linux、IRIX、Solaris、FreeBSD、HP-UX、AIX、macOS),可使用 `cmake` 或 `ccmake` 命令行工具。需要注意的是,`cmake .` 命令默认会构建 **Release 版本**,以确保最终生成的库文件和应用程序具备最佳性能。 ```bash cd OpenSceneGraph cmake . make sudo make install ``` 此外,你也可以创建一个**源码外构建目录**,这种方式的优势在于:CMake 生成的临时文件不会污染 OpenSceneGraph 的源码目录,同时你还可以创建多个独立的构建目录,实现多版本、多配置的并行构建。在 OpenSceneGraph 源码目录的同级目录下,执行以下命令: ```bash mkdir build cd build cmake ../OpenSceneGraph make sudo make install ``` 在 Windows 系统中,请使用 CMake 提供的图形化工具 CMakeSetup,生成 Visual Studio 工程文件。官网维基中专门介绍 CMake 构建系统的页面,可帮助你完成整个流程: http://www.openscenegraph.org/index.php/documentation/platform-specifics/windows 在 macOS 系统中,你既可以使用上述的 CMake 构建流程,也可以直接使用 OpenSceneGraph/Xcode 目录下的 Xcode 工程文件。具体细节请参考下文的 **macOS 系统构建说明**。 如需了解编译、安装和平台专属配置的更多信息,请阅读《快速入门指南》: http://www.openscenegraph.org/index.php/documentation/10-getting-started ## 第二部分:macOS 系统构建说明(作者:埃里克·索科洛夫斯基 等) 在 macOS 系统中编译 OpenSceneGraph 有两种方式。**推荐方式**是使用 CMake 生成 Xcode 工程文件,然后通过 Xcode 构建库文件。默认生成的工程支持构建 Debug 或 Release 版本的库文件、示例程序和测试应用。 另一种方式是直接使用命令行工具(`make` 或 `ninja`),按照上文类 Unix 系统的构建步骤执行即可。 使用 CMake 构建时,有以下几个关键配置项需要注意: - **BUILD_OSG_EXAMPLES**:默认处于关闭状态。开启此选项后,会编译大量功能丰富的示例程序。 - **CMAKE_OSX_ARCHITECTURES**:Xcode 支持为多个 CPU 架构生成应用程序、可执行文件、库和框架。通过此选项可指定 OSG 的构建目标架构。对于 macOS 10.7 及以上版本,仅支持 **x86_64** 架构。 - **OSG_BUILD_APPLICATION_BUNDLES**:默认情况下,示例程序和测试应用只会生成可执行文件。开启此选项后,会生成 macOS 标准的 `.app` 应用程序包。但生成 `.app` 包存在一些注意事项,具体如下。 - **OSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX**:macOS 系统默认使用 `imageio` 插件加载图像文件,而非针对单一格式的独立插件(如 `jpg`、`gif` 插件)。`imageio` 插件通过系统 ImageIO 框架,可支持所有主流图像格式。 - **OSG_WINDOWING_SYSTEM**:在 macOS 上构建应用程序时,可选择 Cocoa、Carbon 或 X11 作为窗口系统。对于 macOS 10.5 及以上版本,默认使用 Cocoa。目前 Carbon 和 X11 已不再被苹果公司或 OSG 社区提供积极支持。 ### 应用程序包(.app 包)说明 以应用程序包形式构建的示例程序,其内部仅包含可执行文件,**不包含运行所需的依赖库**,因此这类程序包通常无法直接移植到其他机器上运行。 此外,以 `.app` 包形式运行的程序,无法自动识别插件的存放路径。你需要手动设置环境变量 **OSG_LIBRARY_PATH**,指定插件(`.so` 文件)的存放目录;同时设置环境变量 **OSG_FILE_PATH**,指定数据文件的存放目录。在测试 OSG 示例程序时,建议将 `OSG_FILE_PATH` 设置为 OpenSceneGraph-Data 数据目录。 许多示例程序运行时需要传入命令行参数。当你通过双击 `.app` 包或在命令行中使用 `open` 命令启动程序时,**只有不需要命令行参数的示例程序才能正常运行**。如果程序需要命令行参数,你需要进入 `.app` 包内部,直接在命令行中执行其中的可执行文件。 ## 第三部分:iOS 系统构建说明(作者:托马斯·霍加斯) 在安装了 CMake 3.11、Xcode 9.4 和 iOS SDK 11.4 的环境下,可通过以下命令行生成 iOS 平台的 Xcode 工程: ```bash export THIRDPARTY_PATH=/path/to/3rdParty cmake ./ -G Xcode -DOSG_BUILD_PLATFORM_IPHONE:BOOL=ON \ -DIPHONE_SDKVER="11.4" \ -DIPHONE_VERSION_MIN="10.0" \ -DOPENGL_PROFILE:STRING=GLES3 \ -DOSG_CPP_EXCEPTIONS_AVAILABLE:BOOL=ON \ -DBUILD_OSG_APPLICATIONS:BOOL=OFF \ -DBUILD_OSG_EXAMPLES:BOOL=ON \ -DOSG_WINDOWING_SYSTEM:STRING=IOS \ -DOSG_DEFAULT_IMAGE_PLUGIN_FOR_OSX="imageio" \ -DDYNAMIC_OPENSCENEGRAPH:BOOL=OFF \ -DDYNAMIC_OPENTHREADS:BOOL=OFF \ -DCURL_INCLUDE_DIR:PATH="$THIRDPARTY_PATH/curl-ios-device/include" \ -DCURL_LIBRARY:PATH="$THIRDPARTY_PATH/curl-ios-device/lib/libcurl.a" \ -DFREETYPE_INCLUDE_DIR_freetype2:PATH="$THIRDPARTY_PATH/freetype-ios-universal/include/freetype" \ -DFREETYPE_INCLUDE_DIR_ft2build:PATH="$THIRDPARTY_PATH/freetype-ios-universal/include" \ -DFREETYPE_LIBRARY:PATH="$THIRDPARTY_PATH/freetype-ios-universal/lib/libFreetype2.a" \ -DTIFF_INCLUDE_DIR:PATH="$THIRDPARTY_PATH/tiff-ios-device/include" \ -DTIFF_LIBRARY:PATH="$THIRDPARTY_PATH/tiff-ios-device/lib/libtiff.a" \ -DGDAL_INCLUDE_DIR:PATH="$THIRDPARTY_PATH/gdal-ios-device/include" \ -DGDAL_LIBRARY:PATH="$THIRDPARTY_PATH/gdal-ios-device/lib/libgdal.a" ``` 请务必将 `THIRDPARTY_PATH` 环境变量设置为你的第三方依赖库所在路径。 - `IPHONE_SDKVER`:设置为你已安装的 iOS SDK 版本,本示例中为 11.4。 - `IPHONE_VERSION_MIN`:控制 Xcode 使用的最低部署系统版本。 - `OPENGL_PROFILE`:设置你想要使用的 OpenGL ES 版本。 命令执行完成后,会在 OSG 根目录下生成 Xcode 工程文件。打开该工程,选择 `example_osgViewerIPhone` 为编译目标,在工程的 **General(通用)** 选项卡中配置开发团队信息。 完成以上步骤后,你就可以编译 `example_osgViewerIPhone` 目标,并将其部署到你的 iOS 设备上运行。 ---