Devana how a browser game is made

15Mar/1115

webGL experiment

I had a school assignment for today. Some algorithm optimization using Newton's discrete method.
The fun thing is that I got to display f(x, y) type functions in 3D space. I chose to do so using the new webGL draft from the html5 suite.
It was a whole lot of fun making it. A colleague created Newton's method code while I just wrote the 3D rendering stuff.

Here's the link: http://devana.eu/misc/newton/newton.html
Keep in mind that since this is a very new draft (v1.0 released on March 3, 2011), not all browsers currently support it.
At the time this post was written, the script was tested and worked on Chrome and Firefox 4 Beta. It might also work in Safari, but It needs testing.

This will surely be a thing of the future as I'm sure lots of great games/applications will be made using it. Even more once the support across browsers will be wide spread.

hints:

Make sure to first press "compute" and then "draw" for the script to work properly.
Also, here is a set of functions I used to test this script:

Math.pow(1-x, 2)+100*Math.pow(y-Math.pow(x,2),2)
x*y
Math.sin(x)*Math.cos(y)
Math.pow(x, 2)-Math.pow(y, 2)
Math.pow(1-x, 2)+100*Math.pow(y-Math.pow(x, 2),2)

For the last one to display properly, use a "z scale" value of 0.0007 as that function conjures high Z values and they won't show up nicely with the default 1 "Z scale".

Enjoy. :)

Filed under: misc 15 Comments