luigi-rosso f17eb06604 Multi backend viewer
Re-works viewer to use GL, Metal, and optionally in the future D3D. Also introduces a new renderer and allows the viewer to be compiled with either Skia or the new example Tess renderer (with either GL or Metal).

I want to re-work the dependency building to be more similar to what Mike did with the third_party directory in a separate PR. It's pretty similar to what's been done here, but generalized at the top level which I think is nice and more re-usable. Also removes the need for some of my path building shell scripts...

There's a new README.md in the viewer directory with some details.

```
cd packages/runtime/viewer/build/macosx
```

Build and run with a Metal backed Skia Renderer:
```
./build_viewer.sh metal skia run
```

Build and run with a GL backed Skia Renderer:
```
./build_viewer.sh gl skia run
```

Build and run with a Metal backed Tess Renderer:
```
./build_viewer.sh metal tess run
```

... and so on

You can also clean directly from the same command:
```
./build_viewer.sh metal tess run clean
```

Diffs=
86d5b0924 Cleanup skia build
83506229a Fix skia dir.
7d4a3bdcf Remove tess to simplify PR.
14346ad9e Nuke old viewer
fba2696cf See clang-format after update
15b8fd753 Remove mat4 test from main rive project
69a2ce9ad Render font cleanup
abd8fa89b Missed files.
e690870a4 Move shader.h and remove formatting for generated files.
afc437b17 Tweaks for failed tests.
2f9a936fc Moving mat4 to tess renderer.
27a3606d6 Cleanup
a4034ff0f Adding viewer readme
bebcd8abe Adding text viewers.
5a1da4ed2 Getting image rendering working in with tess
2c81fee81 Silence deprecation warning.
52f410dfc Getting mesh rendering working.
8de842c7f Starting to use sokol to render meshes. Adding Mat4 class.
dbd5c79b5 Updating clang format for objc
ca0ea9d84 Getting image content working too and fixing contention with sokol
79405a77d Starting to add handle draw support.
8b9f14a16 Adding gl renderer for skia.
af23274ae Adding support for rendering Skia with Metal.
92139ce08 Adding tess renderer.
dc3e1b49b Adding dependencies at top level
22fa8e6ce Updating build scripts
b5cb990aa Merging with latest master.
d08ac18e2 Reorg
a828e92da Updating project json
086890736 Cleanup unused glfw and gl3w for new viewer
55161f36c Using sokol.
72b62b563 Separating GL and TessRenderer.
611b991b6 Adding limits import to fix compilation on all platforms.
820ab8e2f Missed build files.
0964b4416 Stubbing out a generalized viewer and alternate renderer.
2022-07-16 04:21:44 +00:00
2022-07-16 04:21:44 +00:00
2022-07-16 04:21:44 +00:00
2022-07-16 04:21:44 +00:00
2022-06-20 17:44:11 +00:00
2022-07-16 04:21:44 +00:00
2022-07-08 17:01:01 +00:00
2022-07-16 04:21:44 +00:00
2022-07-16 04:21:44 +00:00
2022-07-15 19:38:09 +00:00
2022-07-16 04:21:44 +00:00
2022-06-26 15:54:42 +00:00
2022-07-12 11:18:21 +00:00
2022-07-16 04:21:44 +00:00
2022-07-16 04:21:44 +00:00
2020-08-16 18:20:11 -07:00
2020-07-10 14:15:46 -07:00
2022-02-20 18:59:33 -05:00

Build Status Discord badge Twitter handle

rive-cpp

C++ runtime for Rive. Provides these runtime features:

  • Loading Artboards and their contents from .riv files.
  • Querying LinearAnimations and StateMachines from Artboards.
  • Making changes to Artboard hierarchy (fundamentally same guts used by LinearAnimations and StateMachines) and effienclty solving those changes via Artboard::advance.
  • Abstract Renderer for submitting high level vector path commands with retained path objects to optimize and minimize path re-computation (ultimately up to the concrete rendering implementation).
  • Example concrete renderer written in C++ with Skia. Skia renderer code is in skia/renderer/src/skia_renderer.cpp.

Build System

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 with to support! We encourage you to use premake as it's highly extensible and configurable for a variety of platforms.

Build

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

Building skia projects

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

Testing

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.

Code Formatting

rive-cpp uses clang-format, you can install it with brew on MacOS: brew install clang-format.

Memory Checks

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.

Disassembly Explorer

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"
    }
]
Description
C++ runtime for Rive
Readme 113 MiB
Languages
C++ 89.8%
C 5.5%
Lua 1.7%
Shell 1.7%
Dart 0.9%
Other 0.3%