glGenTextures() question

ok… i dont quite understand the jist of glGenTextures(). i know that if i do glGenTextures(8, ?); w/ an 8, it allows me to have up to 8 textures, but what if the number is unknown. what if i need anywhere between 1 and 150 textures (assuming my gfx can support it)? i would like to call something like glGenTextures(150,?); but i dont know if this is a waste of resources or not. and if i do specify the 150th texture using this method… how do i remove the texture as to save gfx mem? what if i had 150 numbers generated and i wanted to remove the 129th texture w/o altering any of the rest… and make that 129th ‘space’ able to load a different texture later on if i need it… sry, but i cant post source to demonstrate what i need.

glGenTextures( x, y ) generates x textures IDs and stores them in y array. I dont know if it is good or not to generate so many at once and if they all are not needed.
If you want to erase lets say 129th texture you can do as follows:

 UINT uiTextureIDs[ 150 ];

glGenTextures( 150, &uiTextureIDs );

glDeleteTextures( 1, &uiTextureIDs[ 129 ] ); // it will erase 129th texture and it could be used later to allocate sth else

// If you want to delete for example textures from 80 to 95 you can do it as follows

glDeleteTextures( 15, &uiTextureIDs[ 80 ] );

Hope it will help.

[This message has been edited by enmaniac (edited 11-29-2003).]

nice thanks… thats exactly what i was looking for.

Pleased to help ya :slight_smile:

ok… another lol. after i delete the texture, do i need to do glGenTextures(1,?); if i want to use that space again?

if you want to change the content of a texture, just call glTexImage2d with the correct textuerid bound… it will replace the old texture with the new.

and as for glGenTextures… you can call that how many times you want, so if you dont know how many textures you want to use, just call glGenTextures(1,variable) for each texture you load.

If you glDeleteTexture() you have released that textureid. call glGenTexture to get a new one.