2 Copyright (c) 2005-2019 Intel Corporation
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
19 #include <wrl/client.h>
22 #include <d2d1effects.h>
28 #pragma warning (disable: 4449)
30 // Helper utilities to make DirectX APIs work with exceptions
33 inline void ThrowIfFailed(HRESULT hr)
37 // Set a breakpoint on this line to catch DirectX API errors
38 throw Platform::Exception::CreateException(hr);
43 // Helper class that initializes DirectX APIs
44 ref class DirectXBase abstract
50 virtual void Initialize(Windows::UI::Core::CoreWindow^ window, Windows::UI::Xaml::Controls::SwapChainBackgroundPanel^ panel, float dpi);
51 virtual void CreateDeviceIndependentResources();
52 virtual void CreateDeviceResources();
53 virtual void SetDpi(float dpi);
54 virtual void CreateWindowSizeDependentResources();
55 virtual void UpdateForWindowSizeChange();
56 virtual void Render() = 0;
57 virtual void Present();
58 virtual float ConvertDipsToPixels(float dips);
62 Platform::Agile<Windows::UI::Core::CoreWindow> m_window;
63 Windows::UI::Xaml::Controls::SwapChainBackgroundPanel^ m_panel;
66 Microsoft::WRL::ComPtr<ID2D1Factory1> m_d2dFactory;
67 Microsoft::WRL::ComPtr<ID2D1Device> m_d2dDevice;
68 Microsoft::WRL::ComPtr<ID2D1DeviceContext> m_d2dContext;
69 Microsoft::WRL::ComPtr<ID2D1Bitmap1> m_d2dTargetBitmap;
71 // DirectWrite & Windows Imaging Component Objects
72 Microsoft::WRL::ComPtr<IDWriteFactory1> m_dwriteFactory;
73 Microsoft::WRL::ComPtr<IWICImagingFactory2> m_wicFactory;
76 Microsoft::WRL::ComPtr<ID3D11Device1> m_d3dDevice;
77 Microsoft::WRL::ComPtr<ID3D11DeviceContext1> m_d3dContext;
78 Microsoft::WRL::ComPtr<IDXGISwapChain1> m_swapChain;
79 Microsoft::WRL::ComPtr<ID3D11RenderTargetView> m_renderTargetView;
80 Microsoft::WRL::ComPtr<ID3D11DepthStencilView> m_depthStencilView;
82 D3D_FEATURE_LEVEL m_featureLevel;
83 Windows::Foundation::Size m_renderTargetSize;
84 Windows::Foundation::Rect m_windowBounds;
88 #pragma warning (default: 4449)