user1565123
user1565123

Reputation: 89

How to draw a cylinder geometry using webgl?

I need to draw a cylinder geometry using webgl, but don't know how to realize it. The parameters may be radius,subdivisions and two central point of bottom faces.Any ideas will be appreciated,thanks~

Upvotes: 0

Views: 5157

Answers (1)

aaaidan
aaaidan

Reputation: 7316

Fundamentally, you will build it with triangles. It would be easiest to think of it more as an "n-sided" prism. The top and bottom faces will need to be made of triangle "fans", where each triangle shares one point in the center.

You will need to use simple math (including trigonometry) to calculate the locations of the points for each triangle.

If you don't know how to draw triangles with WebGL, check out NeHe's excellent WebGL guide at learningwebgl.com.

Upvotes: 4

Related Questions