void InterlockingTiles::recreateTexture()
{
//Do I need to release this interface to prepare for new data?
if(m_pTexture)
{
m_pTexture->Release();
}
HRESULT hr = m_pDevice->CreateTexture2D(
&m_textureDesc,0,&m_pTexture);
if(FAILED(hr))
{
//TODO: throw some exception
}
}
#1 Members - Reputation: 188
Posted 15 April 2012 - 09:46 AM
#2 Members - Reputation: 3828
Posted 15 April 2012 - 10:06 AM
It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.
#3 Members - Reputation: 188
Posted 15 April 2012 - 10:13 AM
It won't hold it. In fact your m_pTexture should be NULL going into that call.
What does "it won't hold it" mean?
If I have created a texture object and assigned it to the pointer m_pTexture it won't be NULL. If I need to reuse that pointer do I call release and then CreateTexture2D, or am I safe in calling CreateTexture2D without an explicit release (is CreateTexture2D smart enough to release)?
#4 Members - Reputation: 3828
Posted 15 April 2012 - 11:16 AM
Yes, you should Release it before the next call to CreateTexture2D.
If however the new texture is going to be the same size as the previous one you should consider just updating it (via UpdateSubResource for example) instead.
It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.
#5 Members - Reputation: 188
Posted 15 April 2012 - 05:29 PM
Here's another function I have to do just what you suggested.
void InterlockingTiles::setHeightMap( const ID3D11Resource* pSrcTexture )
{
//Copy the contents of the resource into the texture
D3D11_BOX box;
box.left = 0;
box.right = m_textureDesc.Width;
box.top = 0;
box.bottom = m_textureDesc.Height;
box.front = 0;
box.back = 1;
m_pContext->CopySubresourceRegion(m_pTexture, 0, 0, 0, 0, (ID3D11Resource*)pSrcTexture, 0, &box );
}






