the Andrew Bailey

WebGL

Soon after I learned how to program back in 2003 or so, I wanted to program 3D stuff, just because I thought it was cool. Unfortunately, the Python wrapper to OpenGL sucked. Majorly. I could manage, but I had to do without whizzbang features like shaders, framebuffers, and HDR. At least I was happy texturing things and using shadow mapping. I even wrote the article on it.

But man, 3D is hard. Do you know what a matrix is? It's a 2 dimensional grid of numbers. 3D graphics LOVE THEM. To understand 3D, you must understand all the matrices involved and how they interact with all the bits of data flying around. And if you get just a bit of one wrong, the whole thing blows up. Good that my new GPU can do billions of matrix operations every second!

Several years later (~2008), I dipped my toes into C++, only to find out that C++ was harder to use than OpenGL! Using them together was only asking for pain. I must have been masochistic, because I did.

Today, I realize that my JavaScript skills are quite weak. I need to set a goal and challenge myself to use it with something. Sure, I've been using some here and there to fill dropdown boxes, validate some fields, and submit forms, but nothing interesting.

I remember a thing called WebGL. It came out a few years ago, and is a port of OpenGL to JavaScript. Sure, it's been stripped down, but the essentials are there. It requires the use of shaders, you need to manage your own matrices, and it can render to framebuffers. Awesome, this seems to be just what I wanted.

I've been playing around with it, and I want to build a 3D graph and chart engine. My aim is to display web analytics using it. I want to have transparent bar charts and stuff flying around, like they have on the TV news. I've already worked out how to build a sphere out of a icosahedron, along with per-pixel lighting. Sounds like I have a plan.

a multicolored icosahedron

In the big picture, this JavaScript + WebGL platform has the potential to be around for a long time. It's in Firefox and Chrome, and has support on mobile platforms. Due to the rate JavaScript engines have been speeding up, it's not exactly 'slow', and is only going to get faster. It's also easy to get going, provided you know how 3D graphics work. And distributing it could not be easier: just give a URL to someone; no downloading, no installing, no rebooting, no double-clicking. The WebGL feature set nearly matches DirectX 9 level GPUs, so the features it exposes aren't that cutting edge, but it's plenty to make things look decent. We have cleared the 90s, to the point where 3D graphics don't all look like used toilet paper origami.

Posted under Programming. 0 comments.

You can't complain about this anymore. It's perfect!