Skip to content

First pass at C++ docs.#671

Draft
Tod-Rive wants to merge 22 commits into
mainfrom
cplusplus
Draft

First pass at C++ docs.#671
Tod-Rive wants to merge 22 commits into
mainfrom
cplusplus

Conversation

@Tod-Rive
Copy link
Copy Markdown
Contributor

This is mostly Claude generated. I've made some changes to the output but this need a good once-over by someone familiar with the C++ API.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an initial set of C++ runtime documentation pages to the docs site, covering core concepts (File/Artboard/Scene), rendering backends, the render loop, state machines/inputs, data binding, and asset loading, and wires them into the left-nav.

Changes:

  • Added a new runtimes/cpp/ doc section with pages for getting started, rendering, state machines, data binding, asset loading, and external renderer integration.
  • Documented the GPU RenderContext lifecycle (beginFrame/flush), resize handling, and fixed-timestep simulation guidance.
  • Updated docs.json to expose the new C++ section in the “Runtimes” navigation.

Reviewed changes

Copilot reviewed 10 out of 12 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
runtimes/cpp/index.mdx Adds C++ runtime overview page and entry-point links.
runtimes/cpp/getting-started.mdx Adds build + first render-loop walkthrough.
runtimes/cpp/file-and-artboard.mdx Adds file import, artboard querying/instancing, layout sizing, and lifetime guidance.
runtimes/cpp/state-machines.mdx Adds scene lifecycle, pointer forwarding, input access, and state-change introspection.
runtimes/cpp/data-binding.mdx Adds ViewModel runtime/instance/property usage docs and examples.
runtimes/cpp/asset-loading.mdx Adds FileAssetLoader guidance with sync/async examples and caveats.
runtimes/cpp/rendering-loop.mdx Adds detailed beginFrame/flush sequencing, frame descriptors, and operational notes.
runtimes/cpp/renderers.mdx Adds per-backend RenderContext setup snippets (D3D11/12, Metal, Vulkan, GL/WebGL).
runtimes/cpp/external-renderer.mdx Documents implementing Renderer/Factory to plug into custom backends.
docs.json Adds the new C++ pages to the Runtimes sidebar nav.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread runtimes/cpp/file-and-artboard.mdx Outdated
Comment thread runtimes/cpp/file-and-artboard.mdx Outdated
Comment thread runtimes/cpp/file-and-artboard.mdx Outdated
Comment thread runtimes/cpp/state-machines.mdx Outdated
Comment thread runtimes/cpp/state-machines.mdx Outdated
Comment thread runtimes/cpp/external-renderer.mdx Outdated
Comment thread runtimes/cpp/asset-loading.mdx
Comment thread runtimes/cpp/asset-loading.mdx
Comment thread runtimes/cpp/getting-started.mdx
Tod-Rive and others added 2 commits May 11, 2026 18:43
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Tod-Rive and others added 3 commits May 11, 2026 18:51
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 12 changed files in this pull request and generated 6 comments.

Comment thread runtimes/cpp/file-and-artboard.mdx Outdated
Comment thread runtimes/cpp/state-machines.mdx
Comment thread runtimes/cpp/state-machines.mdx Outdated
Comment thread runtimes/cpp/data-binding.mdx
Comment thread runtimes/cpp/getting-started.mdx
Comment thread runtimes/cpp/rendering-loop.mdx
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Tod-Rive Tod-Rive marked this pull request as draft May 12, 2026 15:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 12 changed files in this pull request and generated 7 comments.

Comment thread runtimes/cpp/data-binding.mdx
Comment thread runtimes/cpp/data-binding.mdx
Comment thread runtimes/cpp/data-binding.mdx
Comment thread runtimes/cpp/data-binding.mdx
Comment thread runtimes/cpp/data-binding.mdx
Comment thread runtimes/cpp/getting-started.mdx
Comment thread runtimes/cpp/external-renderer.mdx
Comment thread docs.json
{
"group": "Runtimes",
"pages": [
{
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put this after Unity?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Architecturally I think it makes sense to have core first followed by the wrappers. At least as a dev, that's how I would expect it to flow. Happy to discuss and hear your thoughts.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, but it's also the most complex, the most intimidating, and the least likely for someone to use.

Comment thread runtimes/cpp/index.mdx Outdated
Comment thread runtimes/cpp/index.mdx Outdated
Comment thread runtimes/cpp/overview.mdx
Comment thread runtimes/cpp/overview.mdx
Comment thread runtimes/cpp/state-machines.mdx Outdated
Comment thread runtimes/cpp/state-machines.mdx Outdated
Comment thread runtimes/cpp/state-machines.mdx Outdated
Comment thread runtimes/cpp/state-machines.mdx Outdated
Comment thread runtimes/cpp/state-machines.mdx Outdated
This is the hook you use to react in C++ to states the designer set up — log
analytics, play a sound, fire a callback into your engine.

## Linear animations directly
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Linear animations directly

Not recommended.

Please use Title Case.

This title is a bit of a fragment. Can we do somethig like:
-Running Linear animations directly

  • Linear Animations
  • Running Linear Animations

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed. Should all titles have Title Case?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please.

@Tod-Rive Tod-Rive changed the title Firt pass at C++ docs. First pass at C++ docs. May 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 12 changed files in this pull request and generated 4 comments.

Comment thread runtimes/cpp/overview.mdx
Comment on lines +9 to +10
[Renderer](/runtimes/cpp/external-renderer) — including Rive's own GPU
[Renderer](/runtimes/cpp/renderers) (Metal, Vulkan, D3D11, D3D12, OpenGL/WebGL).
@@ -0,0 +1,129 @@
---
title: "State Machines"
description: "Advance scenes and forward pointer events."
Comment on lines +45 to +48
- `build_rive.sh` (no args) — debug build for the host.
- `build_rive.sh release clean` — clean rebuild.
- `build_rive.sh ninja release` — use Ninja instead of make.
- `build_rive.sh ios release` / `build_rive.sh android release` —
Comment on lines +28 to +73
D3DContextOptions options;
options.isIntel = adapterDesc.VendorId == 0x163C ||
adapterDesc.VendorId == 0x8086 ||
adapterDesc.VendorId == 0x8087;

std::unique_ptr<RenderContext> rc =
RenderContextD3DImpl::MakeContext(device, context, options);

auto* impl = rc->static_impl_cast<RenderContextD3DImpl>();
rcp<RenderTargetD3D> target = impl->makeRenderTarget(width, height);

// Each frame: bind the current backbuffer to the render target.
target->setTargetTexture(backbufferTexture);
```

Swap-chain notes:
- Set `BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT | DXGI_USAGE_UNORDERED_ACCESS`.
- Use `DXGI_FORMAT_R8G8B8A8_UNORM` (or the `_SRGB` variant); other formats
may force the renderer onto an offscreen path.
- Set `options.isIntel = true` on Intel HD Graphics — works around a driver
bug in pixel-local-storage emulation.

For a working reference, see Rive's
[`tests/player`](https://github.com/rive-app/rive-runtime/tree/main/tests/player)
sample app and the D3D-specific wiring in
[`tests/common/offscreen_rendertarget_d3d.cpp`](https://github.com/rive-app/rive-runtime/blob/main/tests/common/offscreen_rendertarget_d3d.cpp).
</Tab>

<Tab title="D3D12">
Header: `rive/renderer/d3d12/render_context_d3d12_impl.hpp`

```cpp
#include "rive/renderer/d3d12/render_context_d3d12_impl.hpp"

using namespace rive::gpu;

ComPtr<ID3D12Device> device;
ComPtr<ID3D12GraphicsCommandList> initList; // recording state

D3DContextOptions options;
std::unique_ptr<RenderContext> rc =
RenderContextD3D12Impl::MakeContext(device, initList.Get(), options);

auto* impl = rc->static_impl_cast<RenderContextD3D12Impl>();
rcp<RenderTargetD3D12> target = impl->makeRenderTarget(width, height);
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants