Description
Changelog
Reviews

Window Capture

This GDExtension adds a node WindowCapture that captures a window (identified by its window title) and provides it as an ImageTexture.

It's tuned for performance and uses the Windows Graphics Capture API. Works at least with Godot 4.6, but should also run on 4.1 and newer.

As of right now, this only supports Windows 11 on x86_64. Support for other platforms is planned.

Usage

The function capture_frame() -> bool is used to capture a frame. This includes creating (or reusing) a session to capture a specific window handle. Upon success this function returns true and get_texture() -> ImageTexture can be used to retrieve the captured window as a texture.

If the window is resized, the size of the provided texture will also change. Closing a captured window will cause capture_frame() -> bool to return false and no new texture will be provided. The extension periodically attempts to capture a new window matching the given title.

Properties

  • window_title: String: The window title to look out for.
  • crop_top: int: Crop the texture at the top side by given amount of pixels.
  • crop_bottom: int: Crop the texture at the bottom side by given amount of pixels.
  • crop_left: int: Crop the texture at the left side by given amount of pixels.
  • crop_right: int: Crop the texture at the right side by given amount of pixels.

Functions

  • capture_frame() -> bool: Try to capture a single frame from a window. true on success, otherwise false.
  • get_texture() -> ImageTexture: Returns the captured frame as an ImageTexture.

Example usage:

extends Node

@onready var capture: WindowCapture = %WindowCapture
@onready var mesh: MeshInstance3D = %MeshInstance3D

func _process(_delta: float) -> void:
    if capture.capture_frame():
        var material := mesh.get_active_material(0)
        material.emission_texture = capture.get_texture()

Changelog for version v0.0.1

No changelog provided for this version.

Reviews (0)

Window Capture has no reviews yet.

Login to write a review.