Cube Defense on FireFox | November 10th, 2009
I have just updated my Cube Defense Demo to work in both WebGL enabled WebKit and FireFox. It is still 10-20fps slower compared to WebKit, but hey, at least it works! I would like to thank those who emailed me tips on making it compatible for both.
To share my experience, these are some of the things I had to change to make it work for WebKit and FireFox:
• Use UNSIGNED_SHORT instead of UNSIGNED_BYTE
• Use CanvasUnsignedShortArray instead of CanvasUnsignedByteArray
• For FireFox, use WebGLFloatArray instead of CanvasFloatArray. This will make things faster.
• ARRAY_BUFFER rather than ELEMENT_ARRAY_BUFFER
• “clearDepth” for WebKit, “clearDepthf” for FireFox
• In “bindBuffer” function use null instead of 0
If you have anything else to add, share your thoughts!
*Update: (November 18th, 09)
This is a little outdated now, so I crossed out some irrelevent stuff. Also, in the lastest WebKit, anything that was CanvasXXXXXArray is now WebGLXXXXXArray.
November 10th, 2009 at 9:54 am
[...] This post was mentioned on Twitter by xnoɹǝʃ uɐıɹq, nonken. nonken said: This is haawt RT @brianleroux Cube Defence by @yoheis now works w/ Firefox WebGL: http://bit.ly/1IXiHr [...]
November 11th, 2009 at 12:36 am
The WebGLFloatArray thing is from a recent spec change, so all implementations will likely rename Canvas*Array to WebGL*Array at some point soon. For backwards compatibility, something like “if (!window.WebGLFloatArray) WebGLFloatArray = window.CanvasFloatArray;” should work (or rename the other way around if your code is using Canvas*Array a lot.)
The SHORT/BYTE problem is probably my doing from back in Canvas3D days, need to fix that :>
November 11th, 2009 at 12:48 am
Great news, thanks for making it work on both platforms! One note — the Firefox guys have fixed the clearDepthf problem now, so clearDepth should work fine on both platforms so long as people have the latest build.
November 11th, 2009 at 12:56 am
[...] it weren’t for Jacob’s demo, this would have been the headline: Yohei Shimomae has updated his great Cube Defense game so that it works on Firefox as well as WebKit. This is excellent news not just because those of us [...]
November 11th, 2009 at 11:33 am
WebKit just updated to a new version of the spec that renames Canvas*Array, Canvas*Object, etc to WebGL*Array and WebGL*Object, etc which means cube defense no longer works in webkit nightlies
November 20th, 2009 at 1:55 am
I would like to protest having to pay $75 for a rapid!
thank you
December 1st, 2009 at 6:19 pm
I made a (short) video of it running in Firefox and posted it on Youtube. Linky: http://www.youtube.com/watch?v=CPPtK8taKA0
Didn’t quite expect Firefox to crash at the last minute, but oh well.
A side note: I can’t get it to run in Chromium; When I run it (with ‘-enable-webgl’ and any of ‘-no-sandbox’ or ‘-disable-sandbox’) the tab crashes and in the terminal it says something about not being able to find libGl.so.1 (or somesuch). I’ve got the nVidia proprietary drivers installed, so that may have something to do with it.
September 6th, 2010 at 5:31 pm
I’ve just tried it in Firefox beta 4, and it doesn’t work. Then again: almost all WebGL pages I could find didn’t work. http://wakaba.c3.cx/w/puls.html and http://www.cs.helsinki.fi/u/ilmarihe/metatunnel.html were the only working I could find without searching too long.
Well, maybe it’s just me and I just need to update some drivers or so.