Example for how to pack an atlas with tools Implements an example Atlas packer (ideally run offline/in a pre-runtime step using the runtime API). Imagine a game engine like Defold using this at edit time/from within engine tooling to pack all the images necessary for all the Rive files in one level into a single Atlas/set of Atlases to minimize state changes when drawing the whole scene. Example implementation is mostly here: packages/runtime/viewer/src/sample_tools The example does both atlas packing and runtime image resolving from the Atlas from the same set of utility classes and their corresponding objects in order to keep the example simple (no serialization of the atlas metadata or pixels). It also uses a very naive packing technique, but it illustrates these main features: 1. find all the image assets in a file 2. packing them sequentially into an atlas 3. ...while building up metadata of where they are in the atlas 4. strips the images from the file 5. shows how to then re-load the file (with no in-band images) and use the generated atlas 6. implements a FileAssetResolver to resolve the images in the Atlas and provide UV transforms Steps 1-4 are what an engine would do at edit/export time. Steps 5-6 show what a runtime would do to then use the files generated in steps 1-4. All of this is implemented in the viewer, minor changes were necessary to the runtime to transform UVs with a transform provided by the RenderImage and fix some bugs. See how the viewer wires this all up here: https://github.com/rive-app/rive/blob/86dbad80c66d9963701d229f637fe5bdc8173090/packages/runtime/viewer/src/viewer_content/scene_content.cpp#L185-L233 Diffs= 38b70a98d Cleanup ac44c1ad7 Fix broken test. 40d2fa966 Fixing UV modification at load time. 736bcf133 Adding an example atlas packer. e42e484eb Starting to add example atlas packer. 438f98716 Adding imgui menu bar
C++ runtime for Rive. Provides these runtime features:
We use premake5. The Rive dev team primarily works on MacOS. There is some work done by the community to also support Windows and Linux. PRs welcomed for specific platforms you wish to support! We encourage you to use premake as it's highly extensible and configurable for a variety of platforms.
In the rive-cpp directory, run build.sh to debug build and build.sh release for a release build.
If you've put the premake5 executable in the rive-cpp/build folder, you can run it with PATH=.:$PATH ./build.sh
Rive makes use of clang vector builtins, which are, as of 2022, still a work in progress. Please use clang and ensure you have the latest version.
cd skia/dependencies ./make_skia.sh // this will invoke get_skia.sh
To build viewer (plus you'll needed CMake installed)
./make_viewer_dependencies.sh
Uses the Catch2 testing framework.
cd dev ./test.sh
In the dev directory, run test.sh to compile and execute the tests.
(if you've installed premake5 in rive-cpp/build, you can run it with PATH=../../build:$PATH ./test.sh)
The tests live in rive/test. To add new tests, create a new xxx_test.cpp file here. The test harness will automatically pick up the new file.
There's a VSCode command provided to run tests from the Tasks: Run Task command palette.
rive-cpp uses clang-format, you can install it with brew on MacOS: brew install clang-format.
Note that if you‘re on MacOS you’ll want to install valgrind, which is somewhat complicated these days. This is the easiest solution (please PR a better one when it becomes available).
brew tap LouisBrunner/valgrind brew install --HEAD LouisBrunner/valgrind/valgrind
You can now run the all the tests through valgrind by running test.sh memory.
If you want to examine the generated assembly code per cpp file, install Disassembly Explorer in VSCode.
A disassemble task is provided to compile and preview the generated assembly. You can reach it via the Tasks: Run Task command palette or you can bind it to a shortcut by editing your VSCode keybindings.json:
[
{
"key": "cmd+d",
"command": "workbench.action.tasks.runTask",
"args": "disassemble"
}
]