Jump to content

  • Log In with Google      Sign In   
  • Create Account

texture problem


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Dannyli   Members   -  Reputation: 135

Like
0Likes
Like

Posted 17 August 2013 - 02:19 PM

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?



Sponsor:

#2 GeneralQuery   Crossbones+   -  Reputation: 1263

Like
0Likes
Like

Posted 17 August 2013 - 03:01 PM

We have no idea what any of these methods do so the first port of call would be to list them.

#3 WiredCat   Members   -  Reputation: 368

Like
2Likes
Like

Posted 17 August 2013 - 04:21 PM

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



#4 BornToCode   Members   -  Reputation: 948

Like
0Likes
Like

Posted 18 August 2013 - 01:02 AM

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.



#5 Dannyli   Members   -  Reputation: 135

Like
0Likes
Like

Posted 26 August 2013 - 12:38 PM

can I use the function: glPushAttrib(); and glPopAttrib();?



#6 Dave Hunt   Crossbones+   -  Reputation: 2478

Like
0Likes
Like

Posted 26 August 2013 - 01:34 PM

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.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS