art with code

2009-11-23

WebGL cubes

Started writing a small scene graph last weekend. Here cube shots from test demo:




I wrote and optimized one use-case for it as well! "Create bouncing cube on canvas (with lighting etc.)"

Ended up with the special-case-rife DWIM snippet: new Scene($('gl_canvas'), new Cube().makeBounce()).

Demos: lots of cubes and a simple bouncing cube.

4 comments:

Giles said...

The demo looks great! Unfortunately although it ran fine on my laptop last night, albeit slowly (it uses software rendering, not sure which version of Minefield), when I run it on the desktop today I get nothing displayed and the following error log:

Error: uncaught exception: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsICanvasRenderingContextWebGL.uniform4fv]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: http://cs.helsinki.fi/u/ilmarihe/demo/gl-util.js :: anonymous :: line 206" data: no]

This is with the latest Minefield.


Cheers,

Giles

Ilmari Heikkinen said...

Oops, sorry about that. Fixed.

I was passing the array length to uniform4fv to make it work on Chrome. And Minefield doesn't ignore the extra arg :(

Giles said...

Cool, that fixed it!

Giles said...

(BTW at Coolcat's suggestion on the forums I've switched to using uniform4f instead of -4fv -- it makes the code a bit uglier but at least means that you can be Chrome- and Minefield-compatible with the same codebase.)

Blog Archive