如何將一個Direct3D 11 2D紋理的任意多邊形區域複製到另一個紋理?我試過使用ID3D11DeviceContext :: CopySubresourceRegion方法,但它只複製矩形部分。我使用Visual C++。將一部分2D紋理複製到另一個Direct3D11
pKeyedMutex11->AcquireSync(1, INFINITE);
pImmediateContext->CopySubresourceRegion(pBackBuffer11, 0, max(size.width-turned,0.0f), 0, 0, pSharedTexture11, 0, &sourceRegion);
pKeyedMutex11->ReleaseSync(0);
pKeyedMutex11_2->AcquireSync(1, INFINITE);
pImmediateContext->CopySubresourceRegion(pBackBuffer11, 0, max(size_1.width - 2*turned,0.0f) , 0, 0, pSharedTexture11_2, 0, &sourceRegion_2);
pKeyedMutex11_2->ReleaseSync(0);
pKeyedMutex11_1->AcquireSync(1, INFINITE);
// Copy the content from the shared texture to the back-buffer
pImmediateContext->CopySubresourceRegion(pBackBuffer11, 0, 0, 0, 0, pSharedTexture11_1, 0, &sourceRegion_1);
pKeyedMutex11_1->ReleaseSync(0);
編輯:添加了代碼片段。
我想它非常有用。你可以引用一些資源來學習使用Stencil Buffers或者提供一些代碼示例,因爲我是DirectX編程的新手。 – 2011-05-23 06:47:10
我假設你使用着色器來渲染圖像。我對嗎? – 2011-05-23 06:53:19
其實我正在做2D動畫。所以基本上我有兩個紋理,我需要複製第一個紋理上的第二個紋理的一部分(如上面所述的多邊形)並改變多邊形。我沒有使用任何着色器。 – 2011-05-23 06:57:37