API reference

Getting started

RASM is a static C++20 library. Your program creates one Engine, asks it for scenes, meshes, materials, cameras and lights, and gets small handles back. Then it calls one function per frame. This page shows how to link RASM, a first program, and the three ways to run a frame.

In short

  • Link with CMake: find_package(rasm) and rasm::rasm, or find_package(rasm COMPONENTS renderer) and rasm::renderer for the renderer alone, without SDL3 and the file loaders' libraries. Ship the shaders next to your executable.
  • Include one header: rasm/rasm.h. Everything is in namespace rasm.
  • From C, or from Python, C#, Rust or Zig: the C API, rasm/rasm_c.h with the shared library rasm_c (find_package(rasm COMPONENTS c) and rasm::c).
  • Every object is a handle. A function that fails logs an error and returns an invalid handle (isValid() is false).
  • Files load in the background. You can use a mesh or texture handle at once; the object is drawn when its data is ready.
  • Call the engine from one thread only. It has no locks.
  • No window needed: a Renderer without a window (or an Engine with PlatformType::HEADLESS) renders frames offscreen, and readFrame copies them back to the CPU (headless).

1The objects you work with

CPU object in the engine GPU buffer
Engine keeps every object below; your code holds only handles Scene entities, cameras, lights Entity mesh, material, Transform Camera projection + controller Light directional, point or spot holds Mesh 1..n sub-meshes SubMesh geometry + material Material PBR or UNLIT Texture up to 6 per material draws default glTF: wins beginFrame uploads what changed Draw lists one per scene Instance table row per sub-mesh Geometry pool vertices + indices Material table row per material Bindless textures 1024 slots
You create the blue objects through Engine functions and keep their handles. The engine keeps the GPU copies (amber) up to date. You never write the GPU tables yourself.
ObjectCreate it withDetails
ScenecreateScenescene.html
Entity (one object in the world)createEntityscene.html
MeshloadMesh (OBJ, glTF) or createMesh (your vertices)scene.html
LightcreateLightscene.html
MaterialcreateMaterialmaterials.html
TextureloadTexturematerials.html
CameracreateCameracamera.html

2Build RASM and link it

  1. Install the tools. CMake 3.23 or newer, Ninja, Clang and vcpkg, with the VCPKG_ROOT environment variable set to it. The Vulkan SDK (1.4) gives the validation layer and the tools; the build does not need it. To run, the machine needs a GPU driver with Vulkan 1.4: RASM loads the Vulkan loader when the engine starts (The Vulkan loader). The step-by-step setup is in docs/build_guide.md.
  2. Build and install RASM. The presets use Ninja and clang++, and vcpkg builds the dependencies. cmake --install copies the library, the public headers and the shaders to install/ in the repo. Debug and Release share that folder, so install both if your project builds both.
    cmake --preset x64-debug            # macOS: --preset macOS
    cmake --build --preset x64-debug
    cmake --install build/x64-debug
    cmake --install build/x64-release   # if you built it too
  3. Find it from your project. Point CMake at the install folder with -DCMAKE_PREFIX_PATH=<repo>/install. To use a build folder without installing, set rasm_DIR to it instead (for example -Drasm_DIR=<repo>/build/x64-debug).
    cmake_minimum_required(VERSION 3.21)
    project(my_app CXX)
    
    find_package(rasm 0.1 CONFIG REQUIRED)
    
    add_executable(my_app main.cpp)
    target_link_libraries(my_app PRIVATE rasm::rasm)   # adds C++20, glm
    # The renderer alone (rasm::Renderer, no Engine or AssetLoader): find_package(rasm 0.1 CONFIG REQUIRED COMPONENTS renderer)
    # and rasm::renderer, which needs no SDL3, tinyobjloader, libktx or LASzip.
    
    # Shaders are compiled at runtime: copy them next to the executable.
    add_custom_command(TARGET my_app POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy_directory "${rasm_SHADER_DIR}" "$<TARGET_FILE_DIR:my_app>/shaders")
  4. Give your project RASM's dependencies. RASM is static, so your executable links its dependencies too. find_package(rasm) looks for them. With vcpkg, add to your manifest: volk, vulkan-headers, vk-bootstrap, vulkan-memory-allocator, glm, sdl3, tracy[on-demand], spdlog, tinyobjloader, meshoptimizer, shader-slang, ktx, laszip and zlib (sdl3, tinyobjloader, ktx and laszip only for rasm::rasm; RASM installs a Findlaszip.cmake beside its config, as the port has no CMake package), and imgui when RASM was built with RASM_IMGUI (the default): the same version as RASM's (1.92.6), built with IMGUI_DISABLE_OBSOLETE_FUNCTIONS in its imconfig.h as RASM's is (copy RASM's overlay port ports/imgui into your overlay ports), or the engine starts with the UI off and logs which struct size differs. Nothing links the Vulkan loader, so your executable runs on a machine without Vulkan until it creates an Engine, which then logs a clear error.
Other ways to add RASM

add_subdirectory(rasm) works too and gives the same rasm::rasm and rasm::renderer targets. Then examples, tests and install rules are off by default. The options are -DRASM_BUILD_EXAMPLES=ON, -DRASM_BUILD_TESTS=ON, -DRASM_INSTALL=ON, -DRASM_ENABLE_AVX2=ON (x86 only), -DRASM_WARNINGS=ON (extra compiler warnings on RASM's own targets), -DRASM_IMGUI=OFF (no Dear ImGui: nothing installed or linked, UI with Dear ImGui), -DRASM_C_IMGUI_EXAMPLE=ON (downloads cimgui for examples/33_c_render_graph's window from C, Dear ImGui from another language) and -DRASM_SHADER_DIR=<path> (the default shader folder, shaders beside the executable).

On Windows the executable needs the dependency DLLs next to it. The examples copy them with rasm_copy_runtime_dlls in cmake/RasmRuntimeDlls.cmake, because vcpkg's own copy misses TracyClient.dll in Debug.

3A first program

This is examples/00_hello_scene/main.cpp made shorter. It loads a mesh and a texture, puts one entity, a camera and a light into a scene, and renders until the window closes (or Esc).

#include "rasm/rasm.h"

int main()
{
    rasm::EngineConfig config = {
        .appName = "my_app",
        .windowWidth = 1280,
        .windowHeight = 720,
        .enableValidation = true,
        .assetRoot = "assets", // relative paths start beside the executable
    };

    rasm::Engine engine(config);
    if (!engine.running())
        return 1; // the reason is in the log

    rasm::SceneHandle scene = engine.createScene();

    // Both return at once. The files are read on a worker thread.
    rasm::MeshHandle mesh = engine.loadMesh("models/obj/bunny/bunny.obj");
    rasm::TextureHandle albedo = engine.loadTexture("models/obj/bunny/bunny-atlas.jpg");
    if (!mesh.isValid() || !albedo.isValid())
        return 1; // unknown format or missing file

    rasm::MaterialHandle material = engine.createMaterial(rasm::MaterialType::PBR, {albedo});
    rasm::EntityHandle bunny = engine.createEntity("bunny", mesh, material,
                                                   rasm::Transform{.position = glm::vec3(0.0f, 0.0f, -10.0f), .scale = glm::vec3(0.005f)});

    rasm::CameraHandle camera = engine.createCamera(
        rasm::CameraProjection{.type = rasm::CameraProjection::Type::PERSPECTIVE,
                               .perspective{.fovY = 45.0f, .aspect = 1280.0f / 720.0f, .nearZ = 0.1f}},
        rasm::Transform{.position = glm::vec3(0.0f, 0.0f, 4.0f)});

    const glm::vec3 sunDirection = glm::normalize(glm::vec3(-0.5f, -0.8f, -1.0f));
    rasm::LightHandle sun = engine.createLight(rasm::LightType::DIRECTIONAL, glm::vec3(1.0f),
                                               glm::vec3(0.0f), sunDirection, 3.0f);

    engine.addEntityToScene(scene, bunny);
    engine.addCameraToScene(scene, camera);
    engine.addLightToScene(scene, sun);

    while (engine.running())
        engine.render(scene, camera); // the bunny appears once its files are loaded
    return 0;
}

What you see

The first frames are empty (dark gray). The bunny appears when its mesh and its texture are both loaded. Drag with the mouse to orbit the camera, scroll to zoom. F1 shows the stats overlay.

What to check when it fails

Read the log (spdlog, on the console). Common causes: no shaders/ folder beside the executable, a wrong assetRoot, or a GPU without Vulkan 1.4. Keep enableValidation on while you develop.

4Handles

FactWhat it means for you
A handle is two numbers, index and generationCopy it freely, store it, compare it with ==. It is not a pointer.
{} is the invalid handleisValid() is false. Many functions take one as "none", for example createEntity without a material.
Errors return the invalid handleThe function logs the reason and returns {}. Check isValid() after creating or loading.
Each kind has its own typeMeshHandle and TextureHandle do not convert into each other, so you cannot pass the wrong kind.
A handle is valid until you destroy its objectEvery object has a destroy* call. A call with a destroyed object's handle logs an error and does nothing, even when a new object took its index. What the GPU may still use is freed once it is done (deferred destruction).

All handle types are listed in Types, handles and limits, with every limit.

5Three ways to run a frame

A · render() one call, the scene's passes B · beginFrame / endFrame your own passes and draws C · RenderGraph::execute passes sorted by what they read beginFrame(camera) Cull 1 · Scene 1 Hi-Z Cull 2 · Scene 2 · Transparent Tone Map · endFrame() if (beginFrame(camera)) beginPass("Main") your draws through RenderContext endPass() endFrame() no scene: only graph passes draw it beginFrame(camera) beginPass(name) yours, or a scene pass endPass() next pass in sorted order endFrame() the engine calls it you call or write it In A and C, barriers come from each pass's reads and writes.
All three run the same frame steps. They differ in who calls them. In B, call nothing when beginFrame returns false: the frame is skipped (window minimized, swapchain out of date).
WayUse it forExampleReference
A · renderOne scene, one camera, straight to the window.00_hello_scene, 02_gltf, 03_instances, 05_cityengine.html#render
B · beginFrame / endFrameA few passes in a fixed order, your own pipelines. It cannot draw a scene: the scene is drawn by graph passes.noneengine.html#beginFrame
C · RenderGraphOffscreen render targets, post effects, compute work, a scene into a render target (addScenePasses). The graph orders the passes and records their barriers.01_render_graph, 04_compute, 06_shadowsrender-graph.html
// B: your own frame. Inside a pass, record with the frame's command buffer.
while (engine.running())
{
    if (!engine.beginFrame(camera))
        continue; // skipped: record nothing, no endFrame
    engine.beginPass("Main");
    // engine.getRenderContext() records draws into
    // engine.getCurrentFrameResources().commandBuffer here
    engine.endPass();
    engine.endFrame();
}

6Where to go next