Hacker News new | past | comments | ask | show | jobs | submit login

I've never used webgl -- what's its advantage over normal 2d canvas drawing for a project like this?



Speed. Drawing thousands of objects (such as the blades of grass or air molecules) with 2D canvas will be very slow. WebGL allows all drawing to be offloaded to the GPU, which can draw thousands of objects in parallel given a single CPU command. 2D canvas also doesn't provide any 3D primitives (as the name would suggest), while WebGL natively supports rasterizing 3D triangles with perspective correct texture mapping and z-buffering.

The downside of WebGL is its complexity, but there are many libraries to help with that.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: