Jump to content
  • Advertisement
Sign in to follow this  
keikei_c

loading multiple textures

This topic is 4291 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'm currently working with lesson 10 at Nehe..texture mapping. I'd like to do something about it, however, i really dont know exactly how. In the tut, the program only loaded 1 texture for all areas (ceiling, floor, etc..)..is it possible to load different texture for every space? can anyone kindly teach me how to manipulate the code? it has something about sectors and stuff..please?

Share this post


Link to post
Share on other sites
Advertisement
you use the bind function to choose which texture is being used in your drawing code:

glBindTexture(GL_TEXTURE_2D, texture_1);
...draw something...

glBindTexture(GL_TEXTURE_2D, texture_2);
...draw something else...



if you go back to lesson 6, where it teaches you how to load a texture, you can use that code to load multiple textures, then use the code I posted above to change which one you are drawing with.

eg.in your initialisation code:

int texture_1, texture_2;

glGenTextures(1, &texture_1);
glGenTextures(1, &texture_2);

glBindTexture(GL_TEXTURE_2D, texture_1);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);


glBindTexture(GL_TEXTURE_2D, texture_2);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[1]->sizeX, TextureImage[1]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[1]->data);


or if you store your texture ID's in an array:

int textures[2];

glGenTextures(2, textures);

glBindTexture(GL_TEXTURE_2D, textures[0]);
glTexImage2D(GL_TEXTURE_2D, ...);


glBindTexture(GL_TEXTURE_2D, textures[1]);
glTexImage2D(GL_TEXTURE_2D, ...);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!