Jump to content

View more

Image of the Day

Working on an auto spawn system. #gamedev #indiedev #screenshotsaturday https://t.co/Mm2kfekz7b
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Using ID3D10Resource question

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
1 reply to this topic

#1 lomateron   Members   

491
Like
0Likes
Like

Posted 18 April 2013 - 10:28 AM

I am doing this code:

 

ID3D10Resource* reSo;

shaderResourceA->GetResource(&reSo);
g_pd3dDevice->CopyResource(Text1,reSo);

shaderResourceB->GetResource(&reSo);
g_pd3dDevice->CopyResource(Text2,reSo);

 

My question is, Where do i have to call Release()?
IS it like THIS:
 
ID3D10Resource* reSo;

shaderResourceA->GetResource(&reSo);
g_pd3dDevice->CopyResource(Text1,reSo);
reSo->Release();

shaderResourceB->GetResource(&reSo);
g_pd3dDevice->CopyResource(Text2,reSo);
reSo->Release();

 

or like THIS:
 
ID3D10Resource* reSo;

shaderResourceA->GetResource(&reSo);
g_pd3dDevice->CopyResource(Text1,reSo);

shaderResourceB->GetResource(&reSo);
g_pd3dDevice->CopyResource(Text2,reSo);

reSo->Release();
reSo->Release();

 

 



#2 mhagain   Members   

13139
Like
0Likes
Like

Posted 18 April 2013 - 12:24 PM

Do it the first way.  The pointer returned by GetResource is going to be different for each call (as GetResource is called on a different shader resource each time), so by doing it the second way you'll (1) leak the resource returned by your first GetResource call, (2) actually destroy the resource returned by your second, and (3) risk crashing when you come to clean up the second for real.


Edited by mhagain, 18 April 2013 - 12:27 PM.

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.





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.