Archived

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

Is there a way to have different textures on a cube?

This topic is 5400 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, I''ve read Nehe''s tutorial on texture mapping, and it uses 1 texture for all 6 faces of the cube. My question is, can you give each face a different texture? I''m asking this question because in the tutorial it says you CANNOT have glBindTexture() inside glBegin() and glEnd(), and since all 6 faces have to be created inside the same glBegin() and glEnd(), how can you speicify a different texture for a face then? If I use a different matrix for each face, would that work smoothly? Or is there an easier way to do it? Thanks for any kind replies. Coco

Share this post


Link to post
Share on other sites
Basically you declare an unsigned int array for the textures, call BindTextures to select one, set all of its mipmapping and other stuff and load the data, then set Bind to the next one and repeat, Bind to the next one and repeat etc etc

Then while you''re drawing, call BindTexture to "select" the "current" texture.

Let me know if you have more questions after checking my program. If you don''t have Visual C++, just check the Initialize() routine in main.cpp and you''ll see how to do it.

Good luck

Share this post


Link to post
Share on other sites
the ^is the binary exclusive-or-operator and a ^= b is the same as a = a^b

here''s an example
a = 10, converted to a binary number that''s 01010
b = 22 = 10110

01010 ^
10110 =
11100 (=28)

the result for each bit is a 1 if ONE, AND ONLY ONE of the corresponding bits of a and b is 1, otherwise it''s 0

hope this helps u

simon

Share this post


Link to post
Share on other sites