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

Texture mapping

Started by WildFire716 Oct 13, 2004 at 9:17 AM 2 replies 500+ views
Original Post
WildFire716
WildFire716
hey seeing im quite new to opengl ive been studying nehes tutorials. well for texture mapping to load the bitmap into memory he uses the glaux library. well after a long time of searching for all the needed components his code works. my question is how does just 2 coordinates plot a texture? for each glVertex3f before it he uses at texture command not quite sure of name atm but it uses 2 coords not 3. is this because he is just plotting x and y for that face and if so can someone explain how to understand the x and y coords? thanks in advance =D
stroma
stroma
no need to define z value on 2d textures.
+-+-+-+-+-STR
CodeMunkie
CodeMunkie
A texture coordinate in OpenGL has a range of 0.0-1.0. Usually, you will see texture coordinates defined as a pair called u,v:
v1.0 ^ |xxxxxxxxxxxx |xxxxxxxxxxxx |xxxxxxxxxxxx |xxxxxxxxxxxx |xxxxxxxxxxxx |xxxxxxxxxxxx0.0----------->1.0 u


A triangle exists in 3D space, the texture exists in 2D space. What you are doing is simply telling OpenGL where a vertex should lay on the texture and then where it should exist in the world. Think of a triangle as silly putty, the vertices as points of the putty you can pull, and the texture as a newspaper comic (did you ever do this as a kid?). You tell OpenGL where to place the vertices of the silly putty on the comic (you give a u,v pair), and then you peel the putty off and you have an image on your putty. Then you can take the putty and stretch it, move it, rotate it, whatever you want to with it. If you put a bunch of those pieces of putty together, you have a monster or a jet or asteroid or whatever image you are trying to produce. I know this is not 100% how OpenGL operates, but it might give you a better conceptual model to work with.
"When you die, if you get a choice between going to regular heaven or pie heaven, choose pie heaven. It might be a trick, but if it's not, mmmmmmm, boy."
How to Ask Questions the Smart Way.
WildFire716
WildFire716
Hey the makes a bit of sence and no i didnt do that as a kid seeing im only 14

Topic Locked

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

Sign in to reply to this topic.