summaryrefslogtreecommitdiffstats
path: root/unityplugin/UnityEmulator/src/UnityGraphicsD3D11Impl.h
blob: 36dfcc1a151a28157f0287c0f40a48349426ea3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#pragma once

#if PLATFORM_WIN32
    #include <d3d11.h>
#elif PLATFORM_UNIVERSAL_WINDOWS
    #include <d3d11_2.h>
#endif

#include <dxgi1_2.h>
#include <atlbase.h>

#include <memory>

class UnityGraphicsD3D11Impl
{
public:
    void CreateDeviceAndContext();
    void CreateSwapChain(void* pNativeWndHandle, unsigned int Width, unsigned int Height);
    void CreateRTVandDSV();
    void Present();
    void ResizeSwapChain(UINT NewWidth, UINT NewHeight);


    ID3D11Device* GetD3D11Device() { return m_d3d11Device; }
    IDXGISwapChain* GetDXGISwapChain() { return m_SwapChain; }
    ID3D11DeviceContext* GetD3D11Context() { return m_d3d11Context; }
    ID3D11RenderTargetView* GetRTV() { return m_BackBufferRTV; }
    ID3D11DepthStencilView* GetDSV() { return m_DepthBufferDSV; }
    UINT GetBackBufferWidth()const { return m_BackBufferWidth; }
    UINT GetBackBufferHeight()const { return m_BackBufferHeight; }
    IDXGISwapChain* GetSwapChain(){ return m_SwapChain; }

private:
    UINT m_BackBufferWidth = 0, m_BackBufferHeight = 0;
    CComPtr<ID3D11Device> m_d3d11Device;
    CComPtr<ID3D11DeviceContext> m_d3d11Context;
    CComPtr<IDXGISwapChain> m_SwapChain;
    CComPtr<ID3D11RenderTargetView> m_BackBufferRTV;
    CComPtr<ID3D11DepthStencilView> m_DepthBufferDSV;
};