Giter Club home page Giter Club logo

rive-cpp-legacy's Introduction

Build Status Discord badge Twitter handle

rive-cpp

Rive hero image

Rive C++ is a runtime library for Rive, a real-time interactive design and animation tool.

The 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_factory.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 wish 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

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.

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"
    }
]

rive-cpp-legacy's People

Contributors

luigi-rosso avatar mikerreed avatar umberto-sonnino avatar mjtalbot avatar jcash avatar mjohnsullivan avatar avivian avatar csmartdalton avatar hermet avatar na2axl avatar taehyub avatar

Stargazers

Yakup Cemil KAYABAŞ avatar  avatar  avatar Gabriel dos Santos Sanches avatar Alex avatar Tail Wag Games avatar piledog avatar Antonio Coratelli avatar  avatar Harry Tran avatar  avatar Fabio Dias Rollo avatar  avatar Zhang Ji Peng avatar sal avatar VIFEX avatar  avatar Daniel dos Santos avatar  avatar RickAi avatar al-sabr avatar kunitoki avatar Selvakumar Jawahar avatar  avatar  avatar Pascal Schmitt avatar exeldapp avatar liquid avatar 2bit avatar @roxlu ☾ avatar Tyler Henry avatar Lee Higgins avatar Denis Denisov avatar Zrurf avatar Tom McKelvey avatar Musab avatar Media Explorer avatar Ayush avatar  avatar Tim-Rex avatar kai avatar Xupeng (Tony) Tong avatar Dian avatar Alexandre Larouche avatar Bjoern Rennhak avatar Adriano Orioli avatar Borin Ouch avatar  avatar Peter Whidden avatar citizenl avatar Mark A. Ropper avatar Zack Brown avatar Shishant Biswas avatar Ahmed Walid avatar Thoth avatar Stanislav Varenkov avatar Roman Tkachev avatar invisageable avatar Vlad Serhiienko avatar Jean-Jacques avatar  avatar  avatar Paulo Poiati avatar Cristian Pallarés avatar Tatsuya Shiozawa avatar  avatar Kishan Devani avatar  avatar iarwain avatar  avatar  avatar Alexander Zizzo avatar TÖRÖK Attila avatar 吴冬亮 avatar Adam Wilson avatar Nolram avatar Jsheng avatar Tim Havlicek avatar Tao Wu avatar sebastian camilo cruz dussan avatar José Antonio avatar xiaoniu avatar Amer Koleci avatar  avatar Josh Santangelo avatar  avatar  avatar  avatar  avatar Jessica Claire Edwards avatar  avatar Kyle Reis avatar Lucas Gama avatar Uli Troyo avatar Rodney avatar Michael Salerno avatar xuty avatar BennyKok avatar  avatar Eric Johnson avatar

Watchers

 avatar  avatar James Cloos avatar emen avatar  avatar Jeremias Bosch avatar Guido Rosso avatar Wiesław Šoltés avatar Roman Tkachev avatar  avatar  avatar Kit [ 潔 ] avatar Mira Grudzinska avatar جابرمقم avatar  avatar

rive-cpp-legacy's Issues

Example using rive and skia

Hi there,

I'm trying to get rive and skia working in a GLFW window but am having trouble. I've only got the old flare examples to go on that I've been able to find. However, a lot seems to have changed since these were written.

Do you have a simple example of at least rendering a rive file to a surface using skia?

Thank you!

Base class for renderer

Use a base class for the video renderer and the PNG sequence renderer: they'll share the resources and some of the functionality they both need.

Use premake to build Win32/Win64

So far I've only been able to configure a 32+64 bit library build using the visual studio solution.
That is also generating only Win32, so you have to clone the config, create a x64 config.
Lastly, you also have to change the dynamic linkage to static.

I think it would be beneficial if it would be possible to use the platform/arch with the build script, e.g.:
build.sh release Win32 / build.sh release Win64

Rive Unity Runtime [Question]

Is this the base repo for the Rive Unity Runtime? Are there any early examples we can play with? It wouldn't take much to determine if Rive is right for my team. Thanks so much!

Windows compilation

Hi,

I was willing to try playing with rive-cpp, so I just added it to my third party cmake, added all cpp files and encountered two errors when building with Visual Studio 2019 :

  • In binary_reader.cpp, readString() method line 45, MSVC does not like the char rawValue[length];. I replaced the code by
std::string result;
result.resize(length);
auto readBytes = decode_string(length, m_Position, m_End, result.data());

and it seems ok (at least it compiles). It might not be the best way to handle that if you want to avoid micro allocations so it might not be the best fix.

  • In shapes/star.cpp, M_PI is not defined. With MSVC, one needs to add _USE_MATH_DEFINES before including math.h. I defined it globally with cmake, but adding the definition before the first cmath include would make more sense.

Are there any interfaces for getting bounds size of the node?

I want to get the node bounds (x,y,w,h) in the rive animation to cover user interaction scenario.
but It seems that there are no interfaces for getting bounds area.
Are there any interfaces for getting bounds area of the node?
Ex) The bound aera of face node is calculated in web design tool already, can I get the same bounds area in rive-cpp runtime?
image
@luigi-rosso

runtime for python

Is there a plan for building runtime for python. there is already a project for skia-python.
Is it even possible?
This will enable python users to render rive animations for desktop applications,

Find a valid zipping library

In order to support generating image sequences, we're going to need a zipping library for compressing and setting up the output.

rive ? flare?

Hi, I'm one of rive users.

I'm wondering the compatibility of flare(flr) animation by new Rive runtime(rive-cpp).

Do you have any plan to support flare animation in this runtime?

There are a plenty of flare animation design resources in community and wondering if they are usable or not here.

Dynamic text, etc?

How can you make text inside a Rive animation dynamic? Eg use Rive for UI? Have a template that text can be loaded in by host language, etc?

TIA

component name is unmatched

To change the instance color during the runtime I named Fills and Strokes as "mycolor" and "mystroke".
but the instance I found is unmatched. (however m_Objects vector container in artboard has the object which I named.)
How can I get the exact instance which I named?

rive::SolidColorBase* fill = (rive::SolidColorBase*)artboard->find("mycolor");
fill->colorValue(rive::colorARGB(255, 0, 0 255));

rive::SolidColorBase* stroke = (rive::SolidColorBase*)artboard->find("mystroke");
stroke->colorValue(rive::colorARGB(255, 0, 255, 255));

image

@luigi-rosso

Need debug and release Skia builds

When we build skia(lib) as a dependency (which we do all over the place) we need to support passing in 'debug' or 'release', so the skialib will 'match' the setting in our tool/app.

This is important not just for performance (release is faster), but occasionally for correctness too ... A header might declare an object differently in those two modes, and if we're not consistent, we could break the ABI at runtime.

Build warnings (non-virtual destructors and comparison of different signedness)

While building, there are some warnings printed:

In file included from ../submodule/rive-cpp/include/rive/artboard.hpp:6,
                 from ../submodule/rive-cpp/include/rive/animation/linear_animation_instance.hpp:4,
                 from ../viewer/viewer.cpp:15:
../submodule/rive-cpp/include/rive/core_context.hpp:9:11: warning: ‘class rive::CoreContext’ has virtual functions and accessible non-virtual destructor [-Wnon-virtual-dtor]
    9 |     class CoreContext {
      |           ^~~~~~~~~~~
In file included from ../submodule/rive-cpp/include/rive/artboard.hpp:11,
                 from ../submodule/rive-cpp/include/rive/animation/linear_animation_instance.hpp:4,
                 from ../viewer/viewer.cpp:15:
../submodule/rive-cpp/include/rive/shapes/shape_paint_container.hpp:14:11: warning: ‘class rive::ShapePaintContainer’ has virtual functions and accessible non-virtual destructor [-Wnon-virtual-dtor]
   14 |     class ShapePaintContainer {
      |           ^~~~~~~~~~~~~~~~~~~
In file included from ../submodule/rive-cpp/include/rive/animation/linear_animation_instance.hpp:4,
                 from ../viewer/viewer.cpp:15:
../submodule/rive-cpp/include/rive/artboard.hpp:28:11: warning: base class ‘class rive::CoreContext’ has accessible non-virtual destructor [-Wnon-virtual-dtor]
   28 |     class Artboard : public ArtboardBase, public CoreContext, public ShapePaintContainer {
      |           ^~~~~~~~
../submodule/rive-cpp/include/rive/artboard.hpp:28:11: warning: base class ‘class rive::ShapePaintContainer’ has accessible non-virtual destructor [-Wnon-virtual-dtor]
In file included from ../submodule/rive-cpp/include/rive/file.hpp:7,
                 from ../viewer/viewer.cpp:22:
../submodule/rive-cpp/include/rive/file_asset_resolver.hpp:9:11: warning: ‘class rive::FileAssetResolver’ has virtual functions and accessible non-virtual destructor [-Wnon-virtual-dtor]
    9 |     class FileAssetResolver {
      |           ^~~~~~~~~~~~~~~~~
../viewer/viewer.cpp: In function ‘void initAnimation(int)’:
../viewer/viewer.cpp:96:29: warning: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
   96 |     if (index >= 0 && index < artboardInstance->animationCount()) {
      |                       ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Test runtime support for JPEG

The attached .riv contains a couple JPEG assets. This is the first test of allowing designers to keep their assets in this format.

TODO:

  • test that this draws correctly on ALL platforms/SDKs
  • test in other environments too (e.g. recorder)

lunch.riv.zip

Static library file size 14 - 16MB (release)

Hi all,

I'm building a release build of rive as a static library.

Compiling using Visual Studio with default toolset (msvc) I get a static lib of 14MB.
Still compiling with VS, but with the clang-cl toolset I get 16MB.

I have a version of rive.lib that I compiled earlier in 2021 that is 1.7MB. I just cannot figure out why it is so big now.!

Any possible way to integrate Rive animations with OBS studio?

So I have created an animation with rive and thinking it to integrate with OBS studio where my chat using commands can change the state of rive animation. So is there any possible way to do the same or if someone can come up with some hint it will be very helpful too. Thanks.

Unable to build with correct debug level

Hi all,

I'm creating static debug builds of all the libraries I'm using (MTd) with LLVM clang, and have it working for all libraries so far except Rive. I've been trying different things for a couple of days. Any help appreciated!

This is my linker output:

1>lld-link : error : /failifmismatch: mismatch detected for '_ITERATOR_DEBUG_LEVEL':
1>>>> skia.lib(skia.SkColorSpace.obj) has value 2
1>>>> rive.lib(binary_reader.o) has value 0

This is my current (part of) premake lua:

filter "configurations:debug"
    buildoptions {"-MTd"}
    debuglevel (2)
    symbols "On"

This is an example of the generated command:

clang++   -MMD -MP -D_USE_MATH_DEFINES -I../include -m64 -g -std=c++17 -Wall -fno-exceptions -fno-rtti -MTd  -o \"obj/debug/artboard.o\" -MF \"obj/debug/artboard.d\" -c \"../src/artboard.cpp\""

Note that I don't think debuglevel (2) has done anything (the command has the same arguments if I leave it off).

Note that all my libraries are built with debug level of 2, but whatever I do I cannot get Rive to build with this level.

Any help appreciated!

Issues building on Ubuntu (16.04)

Opened this issue as a discussion.
I'm not sure if this is reproducible on newer Ubuntu versions (our build server uses 16.04 still).

The problem is X11.h (much like Window.h) adds names to the global namespace, that may fail consequent code.
Although I was able to move the inclusion of X11.h later, I suspect it might not always be as easy for others.

On Ubuntu (16.04), if you happen to include X11.h before the rive headers, you'll get these errors:

In file included from upload/defold-rive/pluginsrc/plugin.cpp:9:
In file included from upload/defold-rive/include/artboard.hpp:6:
In file included from upload/defold-rive/include/generated/artboard_base.hpp:3:
In file included from upload/defold-rive/include/container_component.hpp:3:
In file included from upload/defold-rive/include/generated/container_component_base.hpp:3:
In file included from upload/defold-rive/include/component.hpp:3:
upload/defold-rive/include/component_dirt.hpp:9:3: error: expected identifier
                None = 0,
                ^
/usr/include/X11/X.h:115:30: note: expanded from macro 'None'
#define None                 0L /* universal null resource or null atom */

I'm not sure what a good solution is here, but perhaps a name change to e.g. Empty, Clear, Nilor something similar is acceptable.

FFMPEG uses CBR when bitrate is specified

Our current implementation tries to set a target bitrate but it appears to not force it. It is probably doing some computation to evaluate what's needed and setting the bitrate accordingly.
When we specify a bitrate for the exporter, we want to make sure that value is used in the encoding process.

Hide background

Hi there,

How do I hide the background of the artboard once loaded?
I'd like to hide (make the color transparent, or remove it etc) by default, and allow the user to enable it manually if required.

artboard = file->artboard();
// What to do here to hide background?

Ideally of course the user would create their own assets with transparent background, but this isn't always possible if using third-party assets :)

Cheers,
Peter

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.