• Advertisement

Archived

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

Can Load Multiple Textures, but can not Bind Them

This topic is 6120 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

Hi everybody, I''m having problems trying to get OpenGL to display multiple textures. I can load several textures, but my program only shows the very last texture I loaded. When I make a call to "glBindTexture", I still can''t change to a different texture. I checked all the texture names to make sure that they are valid, and I''ve tried including the "glBindTexture" inside and outside of "gLBegin-glEnd" blocks, but to no avail. Any help will be greatly apprecaited. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
It is because you have the glBindTexture calls in between glBegin and glEnd. Your program works just find when the bind calls are placed in the proper place.

The fanatic is incorruptible: if he kills for an idea, he can just as well get himself killed for one; in either case, tyrant or martyr, he is a monster.
--EM Cioran

Opere Citato

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hi guys and gals,

I really appreciated your help. Thanks a lot!!

Share this post


Link to post
Share on other sites
The best way to handle this is to encapsulate a texture as an object. Use a texture manager to hold texture objects and bind via those objects.

g_pTexManager->AddTexture("textures/image.bmp");
....
g_pTexManager->Use( "textures/image.bmp");
render();


This is a very basic example which can be further optimized, but it''s a start. Also, if you''re going to use a texture manager and get texture pointers on the fly from it, the best data structure to use ultimately would be an array and each index as an id. But sometimes it''s easier to keep track with strings or some other type of key, for this the data structure would be a good choice to hold all of the texture objects.

~David M. Byttow
www.integralstudios.com

Share this post


Link to post
Share on other sites

  • Advertisement