"Removing ressources" in Direct3D ???

Started by
3 comments, last by LEKstor 21 years, 8 months ago
I''ve just the little question about textures and surfaces in Direct3D. Let''s say I''ve created a texture then holding it back in memory using a pointer. When will the texture disappear from memory? After rendering the frame, after clearing the pointer or after reseting the device? My aim: I need a texture-cache for Direct3D cause of I use dynamic textures whose are change every frame.
Someone have stolen my heart,now I have pain.But who was it, and where is my heart now.I cannot live anymore ... cause I can't live without a HEART !!#$%
Advertisement
If you want to remove the texture from memory then

Texture->Release();

If you want to have dynamic texture just set teh texture as

D3DUSAGE_DYNAMIC

when creating it.

Neil

WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!
WHATCHA GONNA DO WHEN THE LARGEST ARMS IN THE WORLD RUN WILD ON YOU?!?!
The solution with "Release" won''t work cause I use the "Visual Basic" version of the Direct3D-Interface (through "dx8vb.dll").
And in this package there''s no function "Release" for textures.
The next problem is that I cannot jump to C++ cause I develop a Engine for VB-Developers.
Someone have stolen my heart,now I have pain.But who was it, and where is my heart now.I cannot live anymore ... cause I can't live without a HEART !!#$%
simply put you create the texture with the DYNAMIC flag. you will then use Lock() to get a pointer to the actual pixel data. you then copy the new image to the texture using poniter. you then call Unlock(). then you can use the texture as normal with SetTexture(0, texture). it is very important that you Lock() the texture when you want to change it. the actual pointer to the image data in the texture may change at any time. also Lock() prevents the texture from being used to render in case the card is attempts to render with that texture while your writing to it. this may occer if your render loop is so fast that the card did not finish rendering the previous frame yet. you must always Unlock() the texture after your done with the Lock() otherwsie you cant use the texture.

NEVER read from the texture since it will be slow. also try to keep the code between the Lock() and Unlock() just copying pixels from some buffer you created to the texture. you could slow the card done of you dont.

the texture will not disappear from memory until you call Release() or minimize the app. when you minimize the app you will get errors when you try to use the texture, you just need to call Restore() (i think, please check the docs).

quote:Original post by LEKstor
The solution with "Release" won''t work cause I use the "Visual Basic" version of the Direct3D-Interface (through "dx8vb.dll").
And in this package there''s no function "Release" for textures.
The next problem is that I cannot jump to C++ cause I develop a Engine for VB-Developers.


If you develop your engine as a DLL, people can use it just fine from VB. If you want to do complex resource management, then VB will let you down. You set the texture to Nothing, and then magically at some point down the road, it''s freed.

So I would do the texture management using C++ in a DLL. That way you have complete control.



Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena

This topic is closed to new replies.

Advertisement