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:
30
host/src/capture/frame_renderer.hpp
Normal file
30
host/src/capture/frame_renderer.hpp
Normal file
@@ -0,0 +1,30 @@
|
||||
// Draws a captured frame texture into the current render target as a letterboxed
|
||||
// full-screen image (aspect-preserved; the cleared background fills the bars).
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <d3d11.h>
|
||||
#include <wrl/client.h>
|
||||
|
||||
namespace coop
|
||||
{
|
||||
|
||||
class FrameRenderer
|
||||
{
|
||||
public:
|
||||
bool init(ID3D11Device* device);
|
||||
|
||||
// Draws `srv` (a srcW x srcH image) centered and scaled to fit within a
|
||||
// dstW x dstH target. Sets its own viewport; callers that draw afterwards
|
||||
// (e.g. ImGui) should restore theirs.
|
||||
void draw(ID3D11DeviceContext* ctx, ID3D11ShaderResourceView* srv, std::uint32_t src_w, std::uint32_t src_h,
|
||||
std::uint32_t dst_w, std::uint32_t dst_h);
|
||||
|
||||
private:
|
||||
Microsoft::WRL::ComPtr<ID3D11VertexShader> vs_;
|
||||
Microsoft::WRL::ComPtr<ID3D11PixelShader> ps_;
|
||||
Microsoft::WRL::ComPtr<ID3D11SamplerState> sampler_;
|
||||
};
|
||||
|
||||
} // namespace coop
|
||||
Reference in New Issue
Block a user