Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Releasing Textures and Buffers

This topic is 6054 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Can anyone tell me why my computer doesn''t like the following... Inside one .cpp file, I have declared some IDirect3DVertexBuffer* ''s and Textures, and I wanted to have a function in another .cpp file to release them...something I could use from anywhere. So in my other .cpp file, the function looks like this void KillTexture(IDirect3DTexture8* texture) { if (texture) { texture->Release(); texture = NULL; } }//end KillTexture And I''d call it from elsewhere like this... IDirect3DTexture8* myTexture; KillTexture(myTexture); But as I mentioned above, things don''t go very smoothly. In fact, the program quits if I attempt to call KillTexture. I do something similar for Buffers and the same problem occurs. Any thoughts?

Share this post

Link to post
Share on other sites
Without a more detailed description of how the Buffers and Textures are declared any attempt to help is pretty much guesswork, but here''s one guess: did you declare the textures and buffers extern in the .cpp file where they were declared?


Version: 3.1
GED d- s:+ a- C++$ UL++ P++ L++ E W+ N+ o K? w !O M--(+) V-- PS+
PE Y+ PGP t-- 5++ X+ R(+) rv+(++) b+++ DI+ D(+) G e+>++ h r--> y+

Share this post

Link to post
Share on other sites
Just by the way, whe you set ''texture'' to NULL in your function, you only set the parameter to NULL.
The variable you used to call the function is not set to NULL this way, unless to pass a reference instead of a copy in your function.

Computer game programmer and part time human being
Strategy First - http://www.strategyfirst.com
BlasterSoft - http://www.blastersoft.com

Share this post

Link to post
Share on other sites
I think the problem is that you''re only updating the local copy of the "myTexture" pointer. The solution is to change your KillTexture function to take a reference to the pointer so it operates on the original:

void KillTexture(IDirect3DTexture8 *&texture)

(Notice the "&").

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!