Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

bochen2k

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

This topic is 6514 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!!!

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!