Skip to Navigation | Skip to Content



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.

Posted in 3d, FireFox, WebGL, WebKit, javascript, openGL | 8 Comments » | Add to Delicious | Digg It

This entry was posted on Tuesday, November 10th, 2009 at 8:55 am and is filed under 3d, FireFox, WebGL, WebKit, javascript, openGL. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

8 Responses to “Cube Defense on FireFox”

  1. Tweets that mention Yohei Shimomae’s Blog » Blog Archive » Cube Defense on FireFox -- Topsy.com Says:

    [...] 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 [...]

  2. Ilmari Heikkinen Says:

    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 :>

  3. Giles Says:

    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.

  4. WebGL around the net, 11 Nov 2009 - Learning WebGL Says:

    [...] 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 [...]

  5. Oliver Says:

    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

  6. Fritz Says:

    I would like to protest having to pay $75 for a rapid!

    thank you

  7. Ben Says:

    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.

  8. Cristan Says:

    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.

Leave a Reply


Search Posts

  • Links

  • Categories