View Full Version : glGenTextures() question
11-28-2003, 06:33 PM
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.
11-28-2003, 11:48 PM
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).]
11-29-2003, 03:07 PM
nice thanks... thats exactly what i was looking for.
11-29-2003, 03:32 PM
Pleased to help ya :-)
12-02-2003, 01:25 PM
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.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.