Use the DXGI surface to create a DXGI render target. Use the swap chain's GetBuffer method to obtain a DXGI surface. Hr = pDXGIFactory->CreateSwapChain(m_pDevice, &swapDesc, &m_pSwapChain) SwapDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT ::ZeroMemory(&swapDesc, sizeof(swapDesc)) Hr = pAdapter->GetParent(IID_PPV_ARGS(&pDXGIFactory)) Hr = pDevice->QueryInterface(&pDXGIDevice) Static const D3D10_FEATURE_LEVEL1 levelAttempts =įor (UINT level = 0 level QueryInterface(&m_pDevice) It selects the best feature level available and falls back to Windows Advanced Rasterization Platform (WARP) when hardware rendering is not available. The following code defines a method that creates an ID3D10Device1. To ensure this support, use the D3D10_CREATE_DEVICE_BGRA_SUPPORT flag when you call the D3D10CreateDevice1 method to create the device. For a list, see Supported Pixel Formats and Alpha Modes.Īdditionally, the ID3D10Device1 associated with the DXGI surface must support BGRA DXGI formats for the surface to work with Direct2D. Regardless of how you create the DXGI surface, the surface must use one of the DXGI formats supported by DXGI surface render targets. Or, you can use a device to create a texture, then use that texture as a DXGI surface. You can create an IDXGISwapChain for a device, then use the swap chain's GetBuffer method to obtain a DXGI surface. With Direct3D 10, there are several ways to obtain a DXGI surface. The DXGI surface render target does not perform DXGI surface synchronization. If you specify the DXGI_FORMAT_UNKOWN format when you create the render target, it will automatically use the surface's format. The DXGI surface render target and the DXGI surface must use the same DXGI format. Like other Direct2D render targets, you can use it to create resources and issue drawing commands. You can then use the DXGI surface render target to draw 2-D content to the DXGI surface.Ī DXGI surface render target is a kind of ID2D1RenderTarget. To write to a Direct3D surface, you obtain an IDXGISurface and pass it to the CreateDxgiSurfaceRenderTarget method to create a DXGI surface render target. Writing to a Direct3D surface with a DXGI surface render target By using CreateSharedBitmap to create an ID2D1Bitmap from an IDXGISurface, you can write a Direct3D scene to a bitmap and render it with Direct2D.You can then use the render target to add a two-dimensional interface or background to three-dimensional graphics, or use a Direct2D drawing as a texture for a three dimensional object. You can write Direct2D content to a Direct3D surface by obtaining an IDXGISurface and using it with the CreateDxgiSurfaceRenderTarget to create an ID2D1RenderTarget.There are two primary ways to use Direct2D and Direct3D together: Direct2D uses DXGI to interoperate with Direct3D. The DXGI runtime layer provides cross-process sharing of video memory surfaces and serves as the foundation for other video memory-based runtime platforms. Interoperability through DXGIĪs of Direct3D 10, the Direct3D runtime uses DXGI for resource management. With DirectX 11.1 or later, Direct2D supports interoperability with Direct3D 11 as well. With DirectX 11.0, Direct2D supports interoperability with Direct3D 10.1 devices only. It also assumes that you can program by using Direct3D 10.1. For a tutorial, see Create a simple Direct2D application. This overview assumes that you are familiar with basic Direct2D drawing operations. This topic describes how to integrate 2-D and 3-D graphics by using Direct2D and Direct3D. There is lots of value that can be added by enabling traditional 2-D rendering to be mixed with Direct3D rendering in an efficient manner. Hardware accelerated 2-D and 3-D graphics are increasingly becoming a part of non-gaming applications, and most gaming applications use 2-D graphics in the form of menus and Heads-Up Displays (HUDs).
0 Comments
Leave a Reply. |