Deleting Textures

Started by
5 comments, last by McGrane 19 years, 9 months ago
Hey all, Im just looking for a function to delete textures from memory and any way to better close my programs.Mainly because most my programs wont close without the ol' ctrl + alt + delete after running for a while lol, so any help would be appericiated like usual ;)
Advertisement
What API are you using?

For OpenGL use glDeleteTextures() ..

And regarding closing your program there is really only one way, by ending the loop. But how you do that depends on the event. Most people use a flag and while it's true they loop, change the flag and the program ends. Just decide when that flag should be changed; eg WM_QUIT or VK_ESCPAPE.
I tried it and one of the param's you have to put into the funtion is ' const GLuint *texture'
But the way i load my Bitmaps comes from the 'Opengl Game Programming' Book, and i use these ...
BITMAPINFOHEADER ShipInfo;
unsigned char* ShipTexture;
unsigned int Ship;
and the glDeleteTextures() function error's because its ..
515 C:\Dev-Cpp\Space Invaders\main.cpp
invalid conversion from `unsigned int' to `const GLuint*'

So should i start using diferent a bmp loading function, or is there another way.

And the loop used is while(!bQuit), and when i tried using bQuit it was 'undeclared' :S

So any other idea's?

[edit] Oops frogot to mention im using opengl in both posts :P

[Edited by - mcgrane66 on July 7, 2004 1:54:11 PM]
and for D3D9 it's IDirect3DTexture9::Release() if I'm not mistaken...

For closing my game, I put the cleanup code into the windows message handler for the case WM_DESTROY. Then if the game is meant to exit [by typing quit at the console, or clicking quit on the menu] it posts a WM_DESTROY message. That message will also be triggered if the X is clicked in windowed mode.
Ok, it's looking like you don't know about pointers. Perhaps you should search the forum or google for a good tutorial as I don't know one off hand..

To free your texture 'ship' which is a unsigned int (the same as a GLuint) you need to tell it to delete 1 texture from it's memory location.

glDeleteTextures( 1, &ship );

The ampersand (&) tells it to use the memory address for the variable 'ship'. GLuint *variable means an unsigned integer pointer, a pointer 'points' to a memory address which is what the & gave to the function.

That's not the best way to explain it, I'm not the best with describing things like this ... I just understand them [wink].
Quote:Original post by Telastyn
For closing my game, I put the cleanup code into the windows message handler for the case WM_DESTROY. Then if the game is meant to exit [by typing quit at the console, or clicking quit on the menu] it posts a WM_DESTROY message. That message will also be triggered if the X is clicked in windowed mode.


I've taken the object oriented approach to my engine, it's all cleaned up in the destructor.
Ok i used pointers like you said Mithoric and it works perfectly,
And i have read about pointers before, but so far have had no real use for them :S , And i didnt know that a GLuint was the same as a unsigned int so thank's for all the help Mithoric and everyone else that tried :D

This topic is closed to new replies.

Advertisement