Logo
Published on

Game Capture & Window Capture

Authors
  • avatar
    Name
    Ryan
    Twitter
Table of Contents

1.1 Graphics APIs

Windows graphics APIs (Graphics Application Programming Interfaces) are software interfaces that allow developers to create and manage graphical content. These APIs serve as an abstraction layer between applications and underlying hardware, enabling rendering without directly manipulating hardware resources.

  1. GDI (Graphics Device Interface): The most basic 2D drawing API on Windows. It relies on the CPU for rendering, has limited performance, and is mainly used in legacy desktop applications.

  2. GDI+: An enhanced version of GDI, supporting anti-aliasing, transparency, complex geometries, and advanced text rendering. Still primarily software-based.

  3. Direct2D: A hardware-accelerated 2D API with significantly better performance than GDI/GDI+, suitable for high-performance drawing.

  4. Direct3D: Part of DirectX, a 3D rendering interface widely used in games and high-performance multimedia.

  5. OpenGL: A cross-platform 2D/3D API, supported via drivers on Windows. Common in professional graphics and some games.

  6. WPF (Windows Presentation Foundation): A vector-based UI system in the .NET framework, supporting animation, styling, and hardware acceleration. Ideal for modern desktop applications.

  7. Vulkan: A low-overhead, cross-platform graphics and compute API by the Khronos Group, offering fine-grained control and extreme performance.

2. Game Process Capture

  • Mechanism: Injects a DLL into the target process to intercept DirectX/OpenGL/Vulkan rendering calls and fetch GPU framebuffer data for sharing with the capture software.

  • Advantages:

    • High performance & low latency: Directly intercepts GPU rendering calls without CPU round-trips; frame rate syncs with GPU rendering.
    • Game-optimized: Fully supports fullscreen exclusive mode and hardware acceleration; compatible with DX9/10/11/12, OpenGL, Vulkan-based games.
  • Disadvantages:

    • Poor compatibility: Doesn’t work with typical desktop applications (e.g., GDI/GDI+ rendering); hard to hook into Electron (Chromium/Skia with multi-process sandboxing).
    • Security and stability risks: Injection mechanisms may be blocked by antivirus or anti-cheat systems and can crash the target application.
    • High maintenance: Requires constant adaptation to new game engines, API versions, and OS security policies.

3. Window Capture

WinRT Screen capture

  • Mechanism: Uses the Windows.Graphics.Capture API to share GPU textures of a specific window or screen via DWM (Desktop Window Manager) and DXGI Desktop Duplication.

  • Advantages:

    • Cross-GPU: Can capture even if OBS and the target window are on different GPUs.
    • Low latency & high performance: Shares GPU textures directly without copying to the CPU, ideal for dynamic content.
  • Disadvantages:

    • Requires Windows 10 1803+: Not available on older Windows 10 versions or Windows 7.

    • Limited Vulkan/DX12 compatibility: Some exclusive fullscreen render paths may not be capturable.

GDI BitBlt

  • Mechanism: Uses the GDI BitBlt function to copy pixel blocks from a source DC to a destination DC. Compatible with older Windows versions.

  • Advantages:

    • Excellent compatibility: Works on Windows 7 and earlier; no special permissions or user interaction required.
    • Simple implementation: Depends solely on GDI, easy to port.
  • Disadvantages:

    • Cannot capture hardware-accelerated windows: GPU-drawn content bypasses the GDI pipeline, resulting in black or corrupted captures.
    • High CPU overhead & latency: Requires GPU-to-CPU data copying; performance and frame rate are constrained.

Magnification API

  • Mechanism: Creates a magnifier window and uses MagSetWindowFilterList to filter target windows, then reads the image from the magnifier's DC.

  • Advantages:

    • Can capture background or occluded windows: Bypasses Z-order restrictions; ideal for capturing hidden windows.
    • Supports hardware-accelerated content: Captures rendered results after DWM composition.
  • Disadvantages:

    • High performance cost: Frequent composition and readback from the magnifier cause high CPU/GPU usage.
    • Depends on Aero/DWM: May not work if Aero is disabled or when third-party themes are used.

4. Recommendations

  1. For high-performance gaming scenarios, Game Process Capture is preferred, followed by WGC (Windows Graphics Capture). Both offer comparable performance, but WGC is safer since it doesn’t use injection.

  2. If compatibility with older systems is needed, consider using BitBlt and Magnification API as fallback options.