Spout 2

repository·master·Indexed 20 days ago

https://github.com/leadedge/spout2

A high-performance video frame sharing system for Windows that enables real-time texture sharing between applications. It supports multiple graphics APIs, including DirectX 9, 11, 12, and OpenGL. The system provides a C-compatible library (SpoutLibrary), a Spout SDK for OpenGL, and support classes for DirectX (SpoutDX). It includes integration examples for Cinder and Openframeworks 12, and supports builds for x86, x64, and Windows on ARM.

Tokens
7.3K
Snippets
12
Records
51
Agent score
76%

What's inside spout2

  1. Overview of Spout video frame sharing

    master

    Spout is a video frame sharing system for Microsoft Windows designed to allow applications to share textures in real-time. It functions similarly to Syphon on macOS. Spout supports sharing textures across different graphics APIs, specifically:

    • DirectX 9
    • DirectX 11
    • DirectX 12
    • OpenGL
  2. Share D3D9ex textures with Spout

    master

    While the Spout SDK Version 2.007 does not have native DirectX9 support, you can still share textures created with D3D9ex if they use specific formats.

    To ensure compatibility, textures must be created with one of the following formats:

    • D3DFMT_A8R8G8B8
    • D3DFMT_X8R8G8B8

    When using these formats, the textures will be successfully received by Spout applications.

  3. Share D3D9ex textures with Spout 2.007

    master

    While the Spout SDK Version 2.007 does not have native DirectX9 support, you can still share textures created with D3D9ex if they use specific formats.

    To ensure compatibility, shared textures must use one of the following formats:

    • D3DFMT_A8R8G8B8
    • D3DFMT_X8R8G8B8

    If these formats are used, the textures will be successfully received by Spout applications even without native SDK support for DX9.

  4. Use SpoutDirectX for DirectX applications

    master

    For applications using DirectX instead of OpenGL, use the SpoutDirectX subset of the SDK.

    • SpoutDX: A support class providing functions similar to the OpenGL version of the SDK.
    • Compatibility: Originally designed for D3D11, but has been extended to support D3D12 and D3D9 with very similar method signatures.
  5. Install Spout libraries to a local folder

    master

    For a more convenient deployment or distribution, build the INSTALL project separately. This will create an INSTALL folder containing the necessary files for use in your development environment.

    # Build the INSTALL target specifically
    cmake --build . --target INSTALL
  6. Integrate SpoutLibrary into a C++ project

    master

    To use SpoutLibrary in your C++ application, follow these integration steps:

    1. Header: Include SpoutLibrary.h in your application's header files.
    2. Linker: Include SpoutLibrary.lib in your project's linker settings. You can use a #pragma comment to specify the path.
    3. Runtime: Ensure SpoutLibrary.dll is placed in the same folder as your application's executable.

    Note: When building the library yourself using Visual Studio 2022, ensure the SpoutGL folder is located at the same level as the SpoutLibrary project folder.

    #include "SpoutLibrary.h"
    
    // Specify SpoutLibrary.lib for the linker
    #pragma comment(lib, "libs/SpoutLibrary.lib")
    
    // Get a pointer to the Spout instance
    // Note: 'sender' type is determined by SpoutLibrary.h
    auto sender = GetSpout();
    
    // Use functions with the library pointer
    sender->OpenSpoutConsole();
  7. Explore Spout DirectX examples

    master

    The Spout SDK provides several DirectX-based examples for testing texture sharing:

    DirectX 11 Examples

    • Basic: Stand-alone versions using Spout SDK classes directly. Useful for understanding how sender texture access and copying is managed. Includes Tutorial04 (sender) and Tutorial07 (receiver).
    • SpoutDX: Uses the SpoutDX support class to simplify implementation. Includes Tutorial04 (sender) and Tutorial07 (receiver).
    • Windows: Desktop application examples that use SendImage and ReceiveImage to transfer pixels without requiring the application itself to call DirectX functions (managed entirely by SpoutDX). Includes Sender and Receiver.

    DirectX 9 & 12 Examples

    • DirectX 9: Uses SpoutDX9.h/cpp. Includes D3D9_Vertices_Sender and D3D9_Vertices_Receiver.
    • DirectX 12: Uses SpoutDX12.h/cpp. Includes D3D12TriangleSender and D3D12TextureReceiver.

    Building Examples

    All examples are compatible with Visual Studio 2022. To build the full suite, open Example.sln, switch the configuration to Release, and select Build > Build Solution. Executables are output to Binaries\Examples.

  8. Install Visual Studio Build Tools for MSBuild

    master

    If you do not have the full Visual Studio IDE installed, you can use MSBuild to build OpenFrameworks example projects by installing the standalone Build Tools.

    1. Download vs_BuildTools.exe from Microsoft's website.
    2. Run the installer.
    3. In the Visual Studio Installer, select Desktop development with C++.
    4. Click Install and wait for completion.
    https://visualstudio.microsoft.com/visual-cpp-build-tools/