Archived

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

escapekiken

how do i retrieve a color from a texture map?

Recommended Posts

I''m trying to implement texture mapping similar to gouraud shading but I''m a bit confused. I have an array of unsigned char in which the texture map is stored, say texture = new unsigned [width*height*3]; After I calculate the coordinates (s,t) after interpolation of the texture coordinates, and I want to look up the color at (s,t) would my color be texture[width*height*s]? That doesn''t seem to work. Any help or insight would be appreciated.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
s and t are the x,y coordinates on the textures'' axis, so s == x, and t == y.

"texture[s+t*textureWidth]" would give you the first of your three bytes in the texture map...

hope this helps

Share this post


Link to post
Share on other sites