Advertisement

Can ANYONE tell me how to load more than one TEXTURE?

Started by February 17, 2001 10:17 AM
0 comments, last by bochen2k 23 years, 9 months ago
I don''t know or CANNOT get it right to load more than one bitmap either one is loadied or the other is loaded but certainly not both at the same time and that causes a big probl;em so can anyone please tell or teach me in some detail how to load more than one bitmap at a time please??? Greatly appreciated!!!
Firstly you need namespace for your n textures:


glGenTextures(n,texnames);


where n is the number of texture names required and texnames is a pointer to an array of n unsigned ints where opengl will save the free texture names.

for each texture you have to do the following:


glBindTexture(GL_TEXTURE_2D,texnames[x]); // I think you''re using 2-dimensional textures, else write GL_TEXTURE_1D or GL_TEXTURE_3D

// GL_REPEAT for texture repeating, GL_CLAMP for clamping
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
// (you could use GL_NEAREST instead of GL_LINEAR)
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);

// load the texture....
glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,x,y,0,GL_RGB,GL_UNSIGNED_BYTE,TexBuf);



where x means the number (not the gl name) of the texture, texnames[x] is the texture number (x should run from 0 to n-1 for n textures)

now you''ve loaded the textures. if you want to use texture nr. y for a polygon, you have to bind it:


glBindTexture(GL_TEXTURE_2D,texnames[y]);

// code for drawing the polygon



now the code to delete the textures from texture memory:


glDeleteTextures(n,texnames);


I hope this helps.

GA
Visit our homepage: www.rarebyte.de.stGA

This topic is closed to new replies.

Advertisement