|
Directx11的窗口已经创建好,并且能正常显示了蓝色背景了,现在想在蓝色背景上刷一张图片,即把一个从bitmap转化好过来的ID3D11Texture2D* D3DTexture,显示到这个窗口当中,请问怎么显示?
const Texture* pTexture = GetTexture(textureId);
if(pTexture && pTexture->D3DTexture)
{
ID3D11DeviceContext* pImmediateContext = NULL;
m_pDevice->GetImmediateContext(&pImmediateContext);
static ID3D11ShaderResourceView* pResourceView = NULL;
D3D11_SHADER_RESOURCE_VIEW_DESC vdesc;
vdesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
vdesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
vdesc.Texture2D.MostDetailedMip = 0;
vdesc.Texture2D.MipLevels = 1;
LRESULT hr = S_OK;
// if (pResourceView == NULL)
{
if (FAILED(hr = m_pDevice->CreateShaderResourceView(pTexture->D3DTexture, &vdesc, &pResourceView))) {
return ;
};
}
if (pTexture->D3DTexture)
{
// D3DTexture 能正常导出到bitmap,所以数据没有问题
static int m_index = 0;
wstring fstr = L"D:\\test\\" + StringHelper::ConvertFromIntW(m_index++) + L".bmp";
SaveToBitmapFile(m_pDevice, pTexture->D3DTexture, fstr.c_str());
}
immediateDeviceContext->IASetPrimitiveTopology( D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP );
immediateDeviceContext>PSSetShaderResources(0, 1, &pResourceView);
immediateDeviceContext->Draw(4, 0);显示不出图片,求大侠,指点指点
|
|