Kiwano Engine v1.3.x
D3D11DeviceResources.h
1// Copyright (c) 2016-2018 Kiwano - Nomango
2//
3// Permission is hereby granted, free of charge, to any person obtaining a copy
4// of this software and associated documentation files (the "Software"), to deal
5// in the Software without restriction, including without limitation the rights
6// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7// copies of the Software, and to permit persons to whom the Software is
8// furnished to do so, subject to the following conditions:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
13// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19// THE SOFTWARE.
20
21#pragma once
22#include <kiwano/macros.h>
23#include <kiwano/render/DirectX/helper.h>
24#include <kiwano/render/DirectX/D3DDeviceResourcesBase.h>
25#include <d3d11.h>
26
27namespace kiwano
28{
29namespace graphics
30{
31namespace directx
32{
33
34MIDL_INTERFACE("3ede2b87-a202-4799-a39b-2308ad34cae8")
35KGE_API ID3D11DeviceResources : public ID3DDeviceResourcesBase
36{
37public:
38 inline ID3D11Device* GetDevice()
39 {
40 KGE_ASSERT(device_);
41 return device_.Get();
42 }
43
44 inline ID3D11DeviceContext* GetDeviceContext()
45 {
46 KGE_ASSERT(device_context_);
47 return device_context_.Get();
48 }
49
50 inline ID3D11RenderTargetView* GetRenderTargetView()
51 {
52 KGE_ASSERT(rt_view_);
53 return rt_view_.Get();
54 }
55
56 inline ID3D11DepthStencilView* GetDepthStencilView()
57 {
58 KGE_ASSERT(ds_view_);
59 return ds_view_.Get();
60 }
61
62 inline IDXGIFactory* GetDXGIFactory()
63 {
64 KGE_ASSERT(dxgi_factory_);
65 return dxgi_factory_.Get();
66 }
67
68 inline IDXGIDevice* GetDXGIDevice()
69 {
70 KGE_ASSERT(dxgi_device_);
71 return dxgi_device_.Get();
72 }
73
74 inline IDXGISwapChain* GetDXGISwapChain()
75 {
76 KGE_ASSERT(dxgi_swap_chain_);
77 return dxgi_swap_chain_.Get();
78 }
79
80protected:
81 ComPtr<ID3D11Device> device_;
82 ComPtr<ID3D11DeviceContext> device_context_;
83 ComPtr<ID3D11RenderTargetView> rt_view_;
84 ComPtr<ID3D11DepthStencilView> ds_view_;
85 ComPtr<IDXGIFactory> dxgi_factory_;
86 ComPtr<IDXGIDevice> dxgi_device_;
87 ComPtr<IDXGISwapChain> dxgi_swap_chain_;
88};
89
90extern ComPtr<ID3D11DeviceResources> GetD3D11DeviceResources();
91
92} // namespace directx
93} // namespace graphics
94} // namespace kiwano