Zengbin
Zengbin

Reputation: 31

Multiple RenderTarget in DirectX 11 (C++)

I want to render a scene and display it on the monitor, while rendering another one to a texture. Do I need to create two swapchains? How do I create the second swapchain in this case? I tried to call CreateSwapChainForCoreWindow but got memory access exceptions.

Upvotes: 3

Views: 3942

Answers (1)

Christian Stieber
Christian Stieber

Reputation: 12496

Swapchains are really just for displaying stuff.

To render to something, you have to add a render target view to the device via the OMSetRenderTargets() call. You can create render target views via CreateRenderTargetView(), which takes a resource as input. Textures are resources too... you just have to create them with the D3D11_BIND_RENDER_TARGET flag.

That's just a few cues that should be able to point you into the right direction.

Btw, Swapchains have buffers, which are resources that are used to create a render target view as well. That's how you render to a swapchain; it really doesn't have anything to do with "swapchains" at all.

Upvotes: 5

Related Questions