WebGLOL

I deviated form my Clojure stuff for a while and made something completely different.

I'm learning OpenGL recently. I've made this silly animation once in Java and wanted to see what it takes to port it to CoffeeScript and WebGL.

Don't Even Wonder If That Means Anything ;-)

Click for full window view

If you see a rectangle only it means you have to get WebGL-enabled browser. It probably won't show up in feed readers because they usually block scripts. If you don't have time to grab a browser, here you have a video of Java version (recording is crappy, I'm new to this also):

You can see the source code just by viewing source of this page or on GitHub (files robots.html and robots.coffee).

Thoughts

I have to say that WebGL is hard. There's a lot you have to know before you draw anything. It's bearable thanks to such great resources as Learning WebGL. I've done that animation only after 3 lessons so pace of this tutorial is really good. One more great thing about it is that examples are using very minimal set of external libraries so it's kind of close to the metal. That animation was made with only addition of CoffeeScript. If you don't want to write everything by hand there's Three.js library.

I also gave CoffeeScript a try and it was worth it. I like that very succinct syntax -- my favorite is anonymous function: it's just -> (compared to JavaScript's function(){}). Some functional programming stuff like list comprehensions and destructuring lists are very welcome too. I don't know much of JavaScript so I can't tell how much writing in CoffeeScript was easier but at least it was more enjoyable :) .

CoffeeScript site make learning it easy. There's even a real-time translator to JavaScript so you can play with language in the browser. What's mentioned almost at the very bottom of document is that you don't have to compile *.coffee to *.js files offline. They can be compiled in the browser. Just include coffee-script.js and tag you scripts with type="text/coffeescript".

blog comments powered by Disqus