【发布时间】:2016-08-25 23:41:41
【问题描述】:
我尝试使用 direct3d 将像素数据作为字节数组映射到动态纹理,由于某种原因,生成的像素数据是黑色的并且它没有被传输。我之前使用 updatesubresource 直接转换了这段代码,但现在我使用 map/unmap。
ID3D11Texture2D* d3dtex = (ID3D11Texture2D*)textureHandle;
assert(d3dtex);
ID3D11DeviceContext* ctx = NULL;
m_Device->GetImmediateContext(&ctx);
D3D11_MAPPED_SUBRESOURCE mappedResource;
ZeroMemory(&mappedResource, sizeof(D3D11_MAPPED_SUBRESOURCE));
// Disable GPU access to the vertex buffer data.
ctx->Map(d3dtex, 0, D3D11_MAP_WRITE, 0, &mappedResource);
// Update the vertex buffer here.
memcpy(mappedResource.pData, dataPtr, textureWidth * textureHeight * 4);
// Reenable GPU access to the vertex buffer data.
ctx->Unmap(d3dtex, 0);
【问题讨论】:
标签: c++ unity3d direct3d11