IDirect3DDevice 介面
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
這代表IDXGIDevice,可用來在需要交換IDXGIDevice參考的Windows 執行階段元件之間進行互通性。
public interface class IDirect3DDevice : IClosable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.Guid(2742428843, 36191, 18000, 157, 62, 158, 174, 61, 155, 198, 112)]
struct IDirect3DDevice : IClosable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.Guid(2742428843, 36191, 18000, 157, 62, 158, 174, 61, 155, 198, 112)]
public interface IDirect3DDevice : System.IDisposable
Public Interface IDirect3DDevice
Implements IDisposable
- 屬性
- 實作
Windows 需求
裝置系列 |
Windows 10 (已於 10.0.10240.0 引進)
|
API contract |
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)
|
範例
// Create a new Windows Console Application (C++/WinRT) project, and
// replace the contents of `pch.h` and `main.cpp` source code files with the code below.
// Be aware that the code below omits the details of obtaining a WinRT Direct3DDevice in
// the first segment of code, and obtaining a native DirectX device in the second segment.
// The code shows only how to perform the conversion between the two.
// pch.h
#pragma once
#include <d3d11_4.h>
#include <Windows.Graphics.DirectX.Direct3D11.interop.h>
#include <unknwn.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.Graphics.DirectX.Direct3D11.h>
// main.cpp
#include "pch.h"
int main()
{
winrt::init_apartment();
// To get the native DirectX device that is wrapped by a Direct3DDevice.
winrt::Windows::Graphics::DirectX::Direct3D11::IDirect3DDevice d3dDevice /* = ... */;
winrt::com_ptr<::Windows::Graphics::DirectX::Direct3D11::IDirect3DDxgiInterfaceAccess> dxgiInterfaceAccess{
d3dDevice.as<::Windows::Graphics::DirectX::Direct3D11::IDirect3DDxgiInterfaceAccess>()
};
winrt::com_ptr<::IDXGIDevice> nativeDevice;
winrt::check_hresult(dxgiInterfaceAccess->GetInterface(
__uuidof(nativeDevice),
nativeDevice.put_void()));
// To create a new Direct3DDevice object wrapping a native DirectX device.
winrt::com_ptr<::IDXGIDevice> nativeDevice2 /* = ... */;
winrt::Windows::Graphics::DirectX::Direct3D11::IDirect3DDevice d3dDevice2{ nullptr };
winrt::check_hresult(::CreateDirect3D11DeviceFromDXGIDevice(
nativeDevice2.get(),
reinterpret_cast<::IInspectable**>(winrt::put_abi(d3dDevice2))));
}
// First include the necessary headers and namespaces.
#include <Windows.Graphics.DirectX.Direct3D11.interop.h>
#include <dxgi.h>
using namespace Windows::Graphics::DirectX::Direct3D11;
using namespace Microsoft::WRL;
// To get the native DirectX device that is wrapped by a Direct3DDevice.
IDirect3DDevice^ d3dDevice = ...;
ComPtr<IDXGIDevice> nativeDevice;
HRESULT hr = GetDXGIInterface(d3dDevice, nativeDevice.GetAddressOf());
// To create a new Direct3DDevice object wrapping a native DirectX device.
ComPtr<IDXGIDevice> nativeDevice = ...;
IDirect3DDevice^ winRTDevice = CreateDirect3DDevice(nativeDevice.Get());
備註
如果您使用 C++/WinRT,則若要在 IDirect3DDevice 與 IDXGIDevice之間來回移動,請使用 IDirect3DDxgiInterfaceAccess::GetInterface 和 CreateDirect3D11DeviceFromDXGIDevice 函式。 您可以在 組合原生交互操作與 DirectX 和 Direct2D中看到另一個程式碼範例。
如果您使用 C++/CX,則若要在 IDirect3DDevice 與 IDXGIDevice之間來回移動,請使用 CreateDirect3DDevice 和 GetDXGIInterface (IDirect3DDevice^,DXGI_TYPE**) 函式。
方法
Dispose() |
執行與釋放 (Free)、釋放 (Release) 或重設 Unmanaged 資源相關聯之應用程式定義的工作。 |
Trim() |
代表應用程式修剪圖形裝置所配置的任何圖形記憶體。 |