D3DXCreateTextureFromResource(...)
Hi
Im using D3DXCreateTextureFromResource to create a texture, and its all good. The texture loads and draws, but then when I shut down, its memory leak-tastic. I am calling Release on the D3DTexture, and setting it to NULL (just in case), but I seem to be getting win32/MFC mem leaks still.
The application is being created in MFC, in case that is the problem?
Anyone had this problem before, and if so, how did you solve it?
Thanks
Are you doing any AddRef()'s after the texture is loaded? If you are, make sure you're performing a Release() for every AddRef() - otherwise, the object's not getting released (its reference count is just being decreased).
Oh, and:
What's indicating that these leaks are happening? Makes it sound like it's a leak from GDI/resources and not DirectX - is that the case? I wouldn't think a D3DXCreateTextureFromResource would lock something in a resource where it was unable to release it properly ... ?
[edited by - chdennis on August 9, 2003 11:56:35 AM]
Oh, and:
quote:I seem to be getting win32/MFC mem leaks still
What's indicating that these leaks are happening? Makes it sound like it's a leak from GDI/resources and not DirectX - is that the case? I wouldn't think a D3DXCreateTextureFromResource would lock something in a resource where it was unable to release it properly ... ?
[edited by - chdennis on August 9, 2003 11:56:35 AM]
No, Im not doing any AddRef calls. I just create the texture once, and thats it.
Its definalty not DirectX mem leaks, as if I comment out the Release() call, then the debug output on shutdown displays :
Direct3D9: (ERROR) :Memory still allocated! Alloc count = 108
Whereas these memory leaks are standard mem leak outputs :
Detected memory leaks!
Dumping objects ->
{162} normal block at 0x01185400, 4212 bytes long.
Data: < iU > 88 69 55 00 16 00 00 00 01 00 00 00 01 00 00 00
Etc...
I did initally think it was MAKEINTRESOURCE(IDB_BITMAP), but if I add that call on its own, then there are no extra memory leaks. The memory leaks only occur if D3DXCreateTextureFromResource(...) succeeds. The leaks also occur if I use D3DXCreateTextureFromFile(...).
Its definalty not DirectX mem leaks, as if I comment out the Release() call, then the debug output on shutdown displays :
Direct3D9: (ERROR) :Memory still allocated! Alloc count = 108
Whereas these memory leaks are standard mem leak outputs :
Detected memory leaks!
Dumping objects ->
{162} normal block at 0x01185400, 4212 bytes long.
Data: < iU > 88 69 55 00 16 00 00 00 01 00 00 00 01 00 00 00
Etc...
I did initally think it was MAKEINTRESOURCE(IDB_BITMAP), but if I add that call on its own, then there are no extra memory leaks. The memory leaks only occur if D3DXCreateTextureFromResource(...) succeeds. The leaks also occur if I use D3DXCreateTextureFromFile(...).
Ive figured out what the problem is, but its just as baffeling!
I override new and delete in _DEBUG mode, using the code example from NeHe (I think thats where its from anyway :$), but it seems that D3DXCreateTextureFromResource(...) calls the overloaded delete operator just fine, but not the overloaded new operator, so when it comes to delete the memory, it doesnt recognise it, so doesnt delete it!
Now this might be a long shot, but has anybody used this function with overloaded opertaors? Im just wondering if the new operator isnt working (as it seems to work just fine in ALL other places), or does the funtion use MALLOC/delete pairs, and as such, messes me up?
Starnge...
Cheers
I override new and delete in _DEBUG mode, using the code example from NeHe (I think thats where its from anyway :$), but it seems that D3DXCreateTextureFromResource(...) calls the overloaded delete operator just fine, but not the overloaded new operator, so when it comes to delete the memory, it doesnt recognise it, so doesnt delete it!
Now this might be a long shot, but has anybody used this function with overloaded opertaors? Im just wondering if the new operator isnt working (as it seems to work just fine in ALL other places), or does the funtion use MALLOC/delete pairs, and as such, messes me up?
Starnge...
Cheers
hello world,
I m using D3DXCreateTextureFromResource too but it''s doesn''t work...
can I have your function D3DXCreateTextureFromResource source code ?? please
dank
I m using D3DXCreateTextureFromResource too but it''s doesn''t work...
can I have your function D3DXCreateTextureFromResource source code ?? please
dank
You can get memory related errors if I don''t set the texture to NULL after releaseing it.
// Instance Texture
IDirect3DTexture9* m_Texture = NULL;
// ... Load and use it ...
// Release it
if( m_Texture != NULL )
{
m_Texture->Release();
m_Texture = NULL;
}
// Instance Texture
IDirect3DTexture9* m_Texture = NULL;
// ... Load and use it ...
// Release it
if( m_Texture != NULL )
{
m_Texture->Release();
m_Texture = NULL;
}
quote:Original post by Anonymous Poster
hello world,
I m using D3DXCreateTextureFromResource too but it''s doesn''t work...
can I have your function D3DXCreateTextureFromResource source code ?? please
dank
Wow I posted this topic months ago!
Why is the function not working, what is it actually doing?
Spree
When you override new/delete, make sure: A new of zero bytes returns a unique non-null pointer to zero bytes. Deleting a NULL pointer succeeds quietly.
xyzzy
xyzzy
I need your help please !! I have seek D3DXCreateTextureFromResource() in the MSDN but it say that I must load my texture( a jpg texture) with RT_RCDATA (??)
what is that ?? how can I use it ?
can you give me your source-code function who you use D3DXCreateTextureFromResource() with a jpg texture please ?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement