While browsing example programs, I noticed that after loading textures using glTextureLoadPVR() there was no code to unload them. I thought it was like this simply because it was not needed for such small demos.
So I tried to use glDeleteTextures(), but it does not seem to work at all.
And the question is, what should I do instead?
For more info, see attached example project.
KGL - textures and memory managment
-
- DCEmu Junior
- Posts: 42
- https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
- Joined: Thu Jul 07, 2016 7:11 pm
- Has thanked: 0
- Been thanked: 6 times
-
- DC Developer
- Posts: 414
- Joined: Thu Aug 20, 2009 11:00 am
- Has thanked: 0
- Been thanked: 2 times
Re: KGL - textures and memory managment
Well, other than not simply doing
you're not closing the texture file after loading it. So you fail on the next pass because it can't open an already opened file.
Code: Select all
glDeleteTextures(6, g_Texture);
Re: KGL - textures and memory managment
...indeed, fixing it took just as much as adding
to the end of glTextureLoadPVR()
Thank you so much! You're a life saver.
Code: Select all
fclose(tex);
Thank you so much! You're a life saver.
-
- DC Developer
- Posts: 414
- Joined: Thu Aug 20, 2009 11:00 am
- Has thanked: 0
- Been thanked: 2 times
Re: KGL - textures and memory managment
You would have run into the fclose problem eventually. As you added more textures, you would have run out of file handles and fopen would start failing. Anywho, this is a good example of the necessity of adding error messages after calls like fopen.