acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
aaa_directx.h
1#pragma once
2
3
4#include <wrl/client.h>
5#include <d3d11_1.h>
6#include <d2d1_1.h>
7#include <dwrite_1.h>
8#include <wincodec.h>
9
10
11namespace universal_windows
12{
13
14
15 inline void throw_if_failed(HRESULT hr)
16 {
17
18 if (FAILED(hr))
19 {
20
21 throw ::exception(hresult_exception(hr));
22
23 }
24
25 }
26
27
28
29
30 // Helper class that initializes DirectX APIs for both 2D and 3D rendering.
31 // Some of the code in this class may be omitted if only 2D or only 3D rendering is being used.
32 ref class directx_base
33 {
34 internal:
35
36
37 bool m_b3D;
38 ::platform::system * system();
39 ::pointer < ::mutex > m_pmutexDc;
40 size m_size;
41 ::windowing::window * m_pimpl;
42 bool m_bInitialized;
43 bool m_bInit;
44 ::image::image_pointer m_pimage;
45
46
47 directx_base();
48
49
50 ::platform::application * get_app() const
51 {
52
53 return get_app();
54
55 }
56
57
58 virtual bool defer_init();
59
60 virtual void Initialize(::winrt::Windows::UI::Core::CoreWindow^ window, ::f32 dpi);
61 virtual void HandleDeviceLost();
62 virtual void CreateDeviceIndependentResources();
63 virtual void CreateDeviceResources();
64 virtual void SetDpi(::f32 dpi);
65 virtual void OnChangeDpi(::f32 dpi);
66 virtual void UpdateForWindowSizeChange();
67 virtual void CreateWindowSizeDependentResources();
68 //virtual HRESULT Render();
69 virtual void Present();
70 void ValidateDevice();
71
72 virtual void OnWindowSizeChange();
73
74 virtual void defer_resize_top_level_windows();
75
76 ID2D1DeviceContext* get_device_context();
77
78 protected private:
79 Agile<::winrt::Windows::UI::Core::CoreWindow> m_window;
80
81 // DirectWrite & Windows Imaging Component Objects.
82 comptr<IDWriteFactory1> m_dwriteFactory;
83 comptr<IWICImagingFactory2> m_wicFactory;
84
85 // DirectX Core Objects. Required for 2D and 3D.
86 comptr<ID3D11Device1> m_d3dDevice;
88 comptr<IDXGISwapChain1> m_swapChain;
89 comptr<ID3D11RenderTargetView> m_d3dRenderTargetImpact;
90
91 // Direct2D Rendering Objects. Required for 2D.
92 comptr<ID2D1Device> m_d2dDevice;
93 comptr<ID2D1DeviceContext> m_pd2d1devicecontext;
94 comptr<ID2D1Bitmap1> m_d2dTargetBitmap;
95
96 // Direct3D Rendering Objects. Required for 3D.
97 comptr<ID3D11DepthStencilView> m_d3dDepthStencilImpact;
98
99 // Cached renderer properties.
100 D3D_FEATURE_LEVEL m_featureLevel;
101 ::winrt::Windows::Foundation::Size m_renderTargetSize;
102 ::winrt::Windows::Foundation::Rect m_windowBounds;
103 ::f32 m_dpi;
104 ::f32 m_dpiIni;
105 //bool m_windowSizeChangeInProgress;
106
107
108
109 //comptr<ID2D1SolidColorBrush> m_blackBrush;
110 //comptr<IDWriteTextFormat> m_textFormat;
111 //comptr<IDWriteTypography> m_textTypography;
112 //comptr<IDWriteTextLayout> m_textLayout;
113 //SampleOverlay^ m_sampleOverlay;
114
115
116 };
117
118
119} // namespace universal_windows
120
121
122
123
124
125//CLASS_DECL_BASE ::pointer < ::mutex > & draw2d_mutex();
Definition comptr.h:18
Definition application.h:64
Definition system.h:53
Definition ___serialization_draft.h:150