Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I texture map a cylinder in OpenGL?

I know how to do quads and that was pretty intuitive with the u,v texture coordinates but I'm having a hard time figuring this out. Any help is appreciated.

like image 337
Xavier Avatar asked Jan 02 '26 08:01

Xavier


1 Answers

Try to think about the parametric representation of a cylinder

cylinder(u, v):
    x = r * cos(u * 2*pi)
    y = r * sin(u * 2*pi)
    z = v

u and v are exactly those values you'd use as texture coordinates.

like image 188
datenwolf Avatar answered Jan 04 '26 04:01

datenwolf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!