Skip to content

Hack the Tower April2013

davidjameshumphreys edited this page Apr 13, 2013 · 1 revision

For the April hack the tower Taneli and David worked on some ClojureScript code.

There was an example of using WebGL, ClojureScript and Ring to serve an example.

Here are some of the things that we learnt over the day:

Original Code:

The original code was found on the LA Clojure meetup page. The code simply took a texture map of the moon and wrapped it onto a sphere.

Our intention was to take it further and to play with the different technologies involved.

lein versions

For the first few hours of the day we spent trying to figure out how to get the code working with the new version of leiningen.

For older versions of lein could use the :dev-dependencies section to start ring. After a while we figured out that we just needed to move the ring dependency to :plugins instead.

Making Changes To The Code

Now that we were armed with a basic understanding of the code we tried to make a change. We saw that the code was closely based on the PhiloGL example 11 code.

So we tried to implement the scroll wheel zoom.

It took a bit of time to do, and most of it was based on looking at the JS code, then copying into ClojureScript.

Changing The Texture

We had the bright idea to try to use different textures in the code so we got a texture map for the earth. It took a while to notice that the texure name was defined twice in the cljs file!

Once we had a texure map that fit into powers-of-two pixels we could display the earth instead.

After a while Taneli found a fix to allow us to use any file as a texture map (dimensions that are not powers of two), this allowed us to show kittens :)

Getting Braver

We tried to implement a simple system where a small drop-down box could specify the type of texture map to use. This is where things got confusing! Which file to edit and where to allow options to pass through caused a lot of problems. In the end there was not enough time to fix it.

Summary:##

It was good to see an example of WebGL within ClojureScript. I am not a ClojureScript/Javascript expert so I was getting lost in the different layers of the code.

Experimenting with the code was hard because there were two processes involved.

  1. The ring web app that was simply serving the resources to us, but it was also generating the main page that setup the javascript rendering.
  2. The ClojureScript part where we would need to compile to javascript to make changes.

For the last part where we tried to use a drop-down box we ended up having tp recompile both parts.