本文整理汇总了C++中microsoft::wrl::ComPtr::CreateShaderResourceView方法的典型用法代码示例。如果您正苦于以下问题:C++ ComPtr::CreateShaderResourceView方法的具体用法?C++ ComPtr::CreateShaderResourceView怎么用?C++ ComPtr::CreateShaderResourceView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类microsoft::wrl::ComPtr
的用法示例。
在下文中一共展示了ComPtr::CreateShaderResourceView方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
void D3DTexture::storeToHardware( Microsoft::WRL::ComPtr<ID3D11Device1> d3dDevice )
{
D3D11_TEXTURE2D_DESC depthBufferDesc;
ZeroMemory( &depthBufferDesc, sizeof( depthBufferDesc ) );
// Set up the description of the depth buffer.
depthBufferDesc.Width = getWidth();
depthBufferDesc.Height = getHeight();
depthBufferDesc.MipLevels = 1;
depthBufferDesc.ArraySize = 1;
depthBufferDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
// depthBufferDesc.Format = DXGI_FORMAT_R8G8B8A8_TYPELESS;
depthBufferDesc.SampleDesc.Count = 1;
depthBufferDesc.SampleDesc.Quality = 0;
depthBufferDesc.Usage = D3D11_USAGE_DEFAULT;
depthBufferDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
depthBufferDesc.CPUAccessFlags = 0;
depthBufferDesc.MiscFlags = 0;
D3D11_SUBRESOURCE_DATA data;
data.pSysMem = getData();
data.SysMemPitch = getWidth()*4*4;
data.SysMemSlicePitch = 0;
ID3D11Texture2D* tex = 0;
// Create the texture for the depth buffer using the filled out description.
DX::ThrowIfFailed(
d3dDevice->CreateTexture2D(&depthBufferDesc, &data, &tex)
);
D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc;
memset( &SRVDesc, 0, sizeof( SRVDesc ) );
SRVDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
SRVDesc.Texture2D.MipLevels = 1;
DX::ThrowIfFailed(
d3dDevice->CreateShaderResourceView( tex, &SRVDesc, &m_pHardwareTextures[0])
);
// m_d3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
// m_d3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
}
示例2: Initialize
bool Initialize(const Microsoft::WRL::ComPtr<ID3D11Device> &device
, const std::shared_ptr<imageutil::Image> &image)
{
D3D11_TEXTURE2D_DESC desc;
desc.Width = image->Width();
desc.Height = image->Height();
desc.MipLevels = 1;
desc.ArraySize = 1;
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0;
desc.Usage = D3D11_USAGE_DEFAULT;
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
desc.CPUAccessFlags = 0;
desc.MiscFlags = 0;
D3D11_SUBRESOURCE_DATA initData;
initData.pSysMem = image->Pointer();
initData.SysMemPitch = image->Stride();
initData.SysMemSlicePitch = image->Size();
auto hr = device->CreateTexture2D(&desc, &initData, &m_texture);
if (FAILED(hr)){
return false;
}
D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc = {};
SRVDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
SRVDesc.Texture2D.MipLevels = 1;
hr = device->CreateShaderResourceView(m_texture.Get(), &SRVDesc, &m_srv);
if (FAILED(hr))
{
return false;
}
D3D11_SAMPLER_DESC samplerDesc;
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
samplerDesc.MipLODBias = 0.0f;
samplerDesc.MaxAnisotropy = 1;
samplerDesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
samplerDesc.BorderColor[0] = 0;
samplerDesc.BorderColor[1] = 0;
samplerDesc.BorderColor[2] = 0;
samplerDesc.BorderColor[3] = 0;
samplerDesc.MinLOD = 0;
samplerDesc.MaxLOD = D3D11_FLOAT32_MAX;
// Create the texture sampler state.
hr = device->CreateSamplerState(&samplerDesc, &m_sampler);
if(FAILED(hr))
{
return false;
}
return true;
}