C/C++: USD Plugin Paths#
This example lists ovrtx’s schema directories, checks their plugin descriptors, and publishes the paths for the bundled USD runtime. Both static and shared loaders use the same source. It takes no arguments and prints its result to the console.
Before running, follow the C/C++ setup. This example uses the loader API without creating a renderer or an ovstage instance. It does not render images.
Start in the public ovrtx repository root, rendering/ovrtx/public in a
Kit checkout. Build and run both loaders with these commands:
cd examples/c/usd-plugin-paths
cmake -B build
cmake --build build --config Release
.\build\static\Release\usd-plugin-paths.exe
.\build\shared\Release\usd-plugin-paths-dynamic.exe
cd examples/c/usd-plugin-paths
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build
./build/static/usd-plugin-paths
./build/shared/usd-plugin-paths-dynamic
Each program prints the plugin directories followed by
Published N schema directories for the bundled USD runtime.,
where N depends on the installed package. No files are generated.
Enumerate and Register Paths#
The following code enumerates borrowed directory strings:
// Returned strings belong to ovrtx and remain valid for this process.
const size_t count = ovrtx_get_usd_plugin_path_count(&config);
std::vector<ovx_string_t> paths(count);
const size_t total = ovrtx_get_usd_plugin_paths(&config, paths.data(), paths.size());
if (total != count || count == 0) return 1;
for (auto path : paths) std::cout << std::string_view(path.ptr, path.length) << "\n";
Enumeration alone does not check the filesystem. The example fails with
Schema plugin descriptor missing: ... and exit code 1 if any enumerated
directory lacks plugInfo.json, including when
OMNI_USD_PLUGINS_BASE_PATH points at a nonexistent root. The CI check runs
this negative case in a new process for each loader.
// Enumeration and registration do not check the filesystem.
for (auto path : paths) {
const auto descriptor = std::filesystem::path(std::string(path.ptr, path.length)) / "plugInfo.json";
std::error_code error;
if (!std::filesystem::is_regular_file(descriptor, error)) {
std::cerr << "Schema plugin descriptor missing: " << descriptor.string() << "\n";
return 1;
}
}
Publish the paths before the bundled USD runtime first uses its registry. In an application that creates ovstage first, do this before initializing ovstage:
// Publish paths before the bundled USD runtime first reads its registry.
const ovrtx_result_t result = ovrtx_register_schema_paths(&config);
if (result.status != OVRTX_API_SUCCESS) {
std::cerr << "Could not register ovrtx schema paths.\n";
return 1;
}
ovrtx_register_schema_paths() always returns OVRTX_API_SUCCESS.
That status does not prove that a USD runtime has loaded the schemas.
The Python example
demonstrates that check with external OpenUSD. An equivalent external C++
OpenUSD check requires that installation’s headers and compatible libraries;
these are not included in the ovrtx C API package.
See USD Plugin Paths and Schema Registration for path ownership and registration order.