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

Started by
4 comments, last by Coconut Crab 21 years, 1 month ago
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
Advertisement
well, easy enough, you just draw one sqaure at a time with a different texture on each square. you''ll end up with six seperate glBegin and glEnd statements.

My Homepage
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
Scroll down to my post Vertex Arrays and Texture Coordinates and download my code if you have Visual C++ 6.0.
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
Hey thanks, Julio. I just visited your website: you are cool!

By the way, what does this sign, ^ , mean in A^? The other formula is pretty cool! 1 less variable to declare ^^.

Coco
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

This topic is closed to new replies.

Advertisement