Jump to content
  • Advertisement
Sign in to follow this  
WildFire716

OpenGL Texture mapping

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

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

Share this post


Link to post
Share on other sites
Advertisement
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:

v
1.0
^
|xxxxxxxxxxxx
|xxxxxxxxxxxx
|xxxxxxxxxxxx
|xxxxxxxxxxxx
|xxxxxxxxxxxx
|xxxxxxxxxxxx
0.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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!