Reputation: 71
I am just wondering if DirectX 11 allows me to set an area to render to instead of rendering the whole window. Thanks a lot!
Upvotes: 4
Views: 2058
Reputation: 71
Finally got it, so to render to a specific rectangle area of your main window application. You first need to create a second childhWnd to let DirectX render to, and then attach this childhWnd to your main hWnd using setParent() to display only one window in total.
Upvotes: 0
Reputation: 1924
Yes, use ID3D11DeviceContext::RSSetViewports
and the D3D11_VIEWPORT
structure. Setting the TopLeftX
, TopLeftY
, Width
, and Height
members to portions of the window dimensions will cause the render target to be drawn into that section of the back buffer.
It's worth noting that this will not prevent DXGI from clearing the whole application window if you create a swap chain against your application's main window handle. If you need to blend Win32 controls and Direct3D content, create a child window specifically for the Direct3D content, create a swap chain against that window, and add the child window to the main application window.
Upvotes: 4