28 lines
617 B
C
28 lines
617 B
C
|
|
#pragma once
|
||
|
|
|
||
|
|
#include <d3d11.h>
|
||
|
|
#include <dxgi1_2.h>
|
||
|
|
#include <wrl/client.h>
|
||
|
|
#include <memory>
|
||
|
|
|
||
|
|
using Microsoft::WRL::ComPtr;
|
||
|
|
|
||
|
|
class ScreenCapture {
|
||
|
|
public:
|
||
|
|
ScreenCapture();
|
||
|
|
~ScreenCapture();
|
||
|
|
|
||
|
|
bool Initialize();
|
||
|
|
bool CaptureFrame(ComPtr<ID3D11Texture2D>& texture);
|
||
|
|
void ReleaseFrame();
|
||
|
|
|
||
|
|
ID3D11Device* GetDevice() const { return device_.Get(); }
|
||
|
|
ID3D11DeviceContext* GetContext() const { return context_.Get(); }
|
||
|
|
|
||
|
|
private:
|
||
|
|
ComPtr<ID3D11Device> device_;
|
||
|
|
ComPtr<ID3D11DeviceContext> context_;
|
||
|
|
ComPtr<IDXGIOutputDuplication> duplication_;
|
||
|
|
bool frame_acquired_ = false;
|
||
|
|
};
|