#### Archived

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.

## 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 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?

-Neophyte

-----BEGIN GEEK CODE BLOCK-----
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+
----- END GEEK CODE BLOCK-----
geekcode.com

##### 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.

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

##### 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 on other sites
Hah. Blaster beat me to it....

1. 1
Rutin
27
2. 2
3. 3
4. 4
5. 5

• 11
• 9
• 9
• 9
• 14
• ### Forum Statistics

• Total Topics
633313
• Total Posts
3011319
• ### Who's Online (See full list)

There are no registered users currently online

×