spout-rs 0.1.3

Rust bindings for Spout2 — GPU texture sharing on Windows
Documentation

spout-rs

crates.io docs.rs

Rust bindings for Spout2 — GPU texture sharing on Windows via DirectX 11 and OpenGL.

Requirements

  • Windows only (Spout2 is a Windows-exclusive library)
  • Spout2 SDK headers — set SPOUT2_SDK_DIR to the directory containing SpoutSender.h (e.g. vendor/Spout2/SPOUTSDK/SpoutGL). Defaults to the vendored submodule when building from a spout-rs clone, so this only needs to be set by downstream consumers.
  • A compiled Spout.lib import library — set SPOUT2_LIB_DIR to its containing directory
  • Spout.dll on PATH at runtime (found in cmake-build/bin/Release after building)

Building

After cloning, run the bootstrap task to install git hooks, initialise submodules, and compile Spout2:

mise run bootstrap

Then set SPOUT2_LIB_DIR before building or running tests:

$env:SPOUT2_LIB_DIR = "vendor\Spout2\cmake-build\lib\Release"   # PowerShell
$env:PATH += ";vendor\Spout2\cmake-build\bin\Release"
cargo build

Consuming from another workspace

The published crate excludes vendor/, so downstream consumers must point the build script at their own copy of the Spout2 SDK headers and import library:

$env:SPOUT2_SDK_DIR = "<path-to-Spout2>\SPOUTSDK\SpoutGL"
$env:SPOUT2_LIB_DIR = "<path-to-Spout2>\cmake-build\lib\Release"

Both can be wired up in a workspace's .cargo/config.toml [env] block with relative = true so developers don't need to set them per-shell.

Usage

Sender

use spout_rs::SpoutSender;

let mut sender = SpoutSender::new("my-sender");
// Each frame, after rendering to a texture:
sender.send_texture(tex_id, gl::TEXTURE_2D, 1920, 1080, false);
sender.hold_fps(60);

Receiver

use spout_rs::SpoutReceiver;

let mut receiver = SpoutReceiver::new(Some("my-sender"));
// Each frame:
if receiver.is_connected() {
    let info = receiver.sender_info(); // name, width, height, fps
    receiver.receive_texture(tex_id, gl::TEXTURE_2D, false);
}

Vendored Libraries