Jump to content
  • Advertisement
Sign in to follow this  
Dannyli

texture problem

This topic is 1881 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 use the following code to generate two textures:

ter=Loadtexture("terrain.bmp",ter);
	cross=Loadtexture("cross.bmp",cross);

but all the objects in the scence are bind with texture 

cross=Loadtexture("cross.bmp",cross);

can someone tell me why?

Share this post


Link to post
Share on other sites
Advertisement

its because the last loaded texture is binded

 

if you want to use a different texture for different faces you must bind it to the face like:

 

glBindTexture(GL_TEXTURE_2D,ter); but i dont know if ter is unsigned int or something else so i just guess

the you draw something

then you change texture

glBindTexture(GL_TEXTURE_2D,anothertex);

and you draw something

Share this post


Link to post
Share on other sites

If every object is getting drawned with the second texture. It means that your load texture function is binding the resource been loaded. If you want to draw using the first texture then you need to bind that one.

Share this post


Link to post
Share on other sites

Yes, but that is really not their intended use. You should always bind the texture you want to draw with before drawing. You can never be sure what other pieces of code (particularly anything living in a library you didn't write) might be doing behind your back.

 

The best practice is to always explicitly set whatever states/attributes you need when drawing. That way you aren't caught by surprise when some black box function does something without telling you.

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!