Phase 1b: video mirror via Windows Graphics Capture
Mirror the injected game's window into the host's borderless window so Steam RPT streams a live copy of the game. No injection needed for video. - capture/window_capture: WGC capture of a target HWND. Wraps our D3D11 device as an IDirect3DDevice, creates a free-threaded frame pool + capture session, hides the cursor and (best-effort) the capture border. Frames arrive on a WGC thread and are handed to the render thread, which copies the newest into a shader-resource texture and draws it -- keeping all D3D11 context use on one thread. Handles window resize via frame-pool Recreate. - capture/frame_renderer: fullscreen-triangle shader that blits the captured texture letterboxed (aspect-preserved) into the window. - capture_panel: "Mirror game window" toggle + lifecycle; target HWND comes from the hook's reported game window. - main: winrt apartment init; mirrored frame drawn as background, ImGui on top. - CMake: link windowsapp + d3dcompiler. Verified: builds clean; host starts (apartment init + shader compile succeed). Visual capture quality/latency to be judged on a real game. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
40
host/src/capture_panel.hpp
Normal file
40
host/src/capture_panel.hpp
Normal file
@@ -0,0 +1,40 @@
|
||||
// Owns the video-mirror pipeline (WGC capture + frame renderer) and its UI.
|
||||
// The target window comes from the injected hook's reported game HWND.
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <d3d11.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "capture/frame_renderer.hpp"
|
||||
#include "capture/window_capture.hpp"
|
||||
|
||||
namespace coop
|
||||
{
|
||||
|
||||
class CapturePanel
|
||||
{
|
||||
public:
|
||||
bool init(ID3D11Device* device);
|
||||
|
||||
// The window to mirror (0 if none yet); typically the injected game's HWND.
|
||||
void set_target(HWND target)
|
||||
{
|
||||
target_ = target;
|
||||
}
|
||||
|
||||
void draw_ui();
|
||||
|
||||
// Render thread: draw the mirrored frame as the window background.
|
||||
void render(ID3D11DeviceContext* ctx, std::uint32_t dst_w, std::uint32_t dst_h);
|
||||
|
||||
private:
|
||||
ID3D11Device* device_ = nullptr;
|
||||
FrameRenderer renderer_;
|
||||
WindowCapture capture_;
|
||||
HWND target_ = nullptr;
|
||||
bool enabled_ = false;
|
||||
};
|
||||
|
||||
} // namespace coop
|
||||
Reference in New Issue
Block a user