Skip to main content
GameDev.net gamedev.net
🔒 Locked

Quick Texture Mapping Question

Started by NPComplete Nov 21, 2000 at 5:02 PM 0 replies 350+ views
Original Post
NPComplete
NPComplete
I have a large texture, and i have 4 different textures inside it...(2 x 2), for example, i got a rock texture int he upperleft, a brick texture upper right, water texture lowerleft, and sand texture lower right.....Now, i would like to bind that texture like we always do, but is there a way i can texture a square with the water side, then texture another square witht he rock side? I can do this with 4 different textures, but how can i do this with all these pieces inside the texture? This is a simplified version of the problem im trying to solve which is a 16x16 piece texture...if someone could show me how to solve the 4x4, the 16x16 should be a piece of cake! -NPC thanx in advance
DemOSh
DemOSh
This one is easy

for the lower left texture do this:

glTexCoord2f(0.0f, 0.0f); glVertex3f(lower left pt of quad);
glTexCoord2f(0.0f, 0.5f); glVertex3f(upper left pt of quad);
glTexCoord2f(0.5f, 0.5f); glVertex3f(upper right pt of quad);
glTexCoord2f(0.5f, 0.0f); glVertex3f(lower right pt of quad);

for the upper left texture do:

glTexCoord2f(0.0f, 0.5f); glVertex3f(lower left pt of quad);
glTexCoord2f(0.0f, 1.0f); glVertex3f(upper left pt of quad);
glTexCoord2f(0.5f, 1.0f); glVertex3f(upper right pt of quad);
glTexCoord2f(0.5f, 0.5f); glVertex3f(lower right pt of quad);

you get the idea. just use texcoords to indicate the region you want from the big texture. For the 16*16 texture, one texture, you just have to figure out the texcoords for the corners of each texture. the bottom left of the texture is 0,0 and the upper right is 1,1

Why do you need everything in one big texture though? wouldnt it be easier to store them seperately?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.