Create your first runtime¶
Create RendererRuntime on the thread that will own its live state. This example uses the Null backend and opens one host frame. It needs no window, GPU surface, shaders, or imported assets. Check the result at each boundary and report the diagnostic message.
#include <iostream>
#include <utility>
#include <Renderer/Runtime/RendererRuntime.h>
int main()
{
using namespace SnAPI::Renderer;
RendererConfig config{};
config.PreferredBackend = EGraphicsBackend::Null;
auto created = RendererRuntime::Create(config);
if (created.Failed())
{
std::cerr << created.Error().Message << '\n';
return 1;
}
auto runtime = std::move(created).Value();
// Open and close one host frame on the runtime owner. No window is needed.
if (auto began = runtime->BeginFrame({}); began.Failed())
{
std::cerr << began.Error().Message << '\n';
return 1;
}
if (auto ended = runtime->EndFrame(); ended.Failed())
{
std::cerr << ended.Error().Message << '\n';
return 1;
}
return 0;
}
RendererRuntime::Create returns an owning runtime on success. The runtime
owns the device and exposes its systems, including presentation, materials,
shaders, lights, volumes, and frame graphs. A handle created by one runtime
must stay with that runtime.
A successful BeginFrame opens a scope. Pair it with EndFrame even if a
later submission fails or returns a deferred status. The frame here contains
no submissions. For a target submission and GPU completion, see
Render to a texture.
Move the same ownership model to a real host¶
Start from RendererConfig::DefaultPresentation() when requesting the
built-in presentation backend. Check the resulting capabilities and handle an
unavailable backend explicitly. Attach a presentation target through the
runtime’s presentation system, then prepare the scene and profile before
drawing. See Present in a window.