Hacker News new | past | comments | ask | show | jobs | submit login
WebGL in Firefox Nightly Builds (vlad1.com)
42 points by e1ven on Sept 19, 2009 | hide | past | favorite | 16 comments



This is great, a single standard being implemented in WebKit AND Firefox. Someone will probably have to write a plugin for IE though, since it's HIGHLY doubtful Microsoft would cooperate.


It's frustrating that this is the state we're in.

We've got just about everyone EXCEPT the major browser vendor working on cool, useful, forward-thinking innovations, and standardizing on them with relative ease. Yet all of this innovation is so sorely limited without Microsoft's contribution (to IE).

Normally I just nod my head and move on, but the future doesn't look any brighter for IE. Hopefully Microsoft's halfhearted interest in HTML5 will improve.

But then again, MS could drop WebKit into IE9, and we'd still be stuck, unless Microsoft shoves IE9 down the Automatic Update pipeline as a required update. Which they should, IMHO. Progress is worth some pain.


We've got just about everyone EXCEPT the major browser vendor working on cool, useful, forward-thinking innovations, and standardizing on them with relative ease. Yet all of this innovation is so sorely limited without Microsoft's contribution (to IE).

Microsoft's ActiveX has been around for a long time. And I remember a little something called VRML that was supported by the major browsers of the time.


I'm looking more for something community-or-compatibility driven. The web community pushes for certain things; when everyone except IE gets on board, Microsoft should strive to pursue those standards.

Poor word choice on my part: Microsoft has innovated before, yes. They're innovating now in various spaces. But they're dragging their feet in areas that could really boost the web as a platform, and that slows progress.


It scares them to have the web as a platform as it marginalizes two of it's cash cows: Office and Windows.

Them not innovating is actually a smart business decision from their angle.


1994, and SGI IRIX already shipped with browser plugin for 3D and 3d content creator. even the lowly 8bit indy could handle it. VRML at it's best (if it had any best...)

The 5.3 or 6.2 version of Irix (do not recall which one, the one that shipped with netscape 2.0) also had all the admin apps written in html+javascript, but completely merged with the OS look n feel. you simply couldn't tell.


I just downloaded and installed the latest Minefield nightly. I enabled the single webgl option in about:config.

Not a single one of the examples from http://trac.webkit.org/changeset/48330 are loading for me.

They all error with:

Error: uncaught exception: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIDOMHTMLCanvasElement.getContext]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: http://trac.webkit.org/export/48330/trunk/WebCore/manual-tes... :: initWebGL :: line 19" data: no]

etc.

Anyone on here get it working?


the offending line is: var gl = canvas.getContext("webkit-3d");

I tried to change it to all the values I found on developer's blogs and even in the Painting the Web Oreily book.

"3d", "-moz-webgl2.0", "webgl2.0", "webgl", "gl", "moz-gles11"

All got me the same NS_ERROR_ILLEGAL_VALUE


tried to grep the source. but all I could find was

// IID for the nsIRenderingContext interface

// 37762dd8-8df0-48cd-a5d6-24573ffdb5b6

#define NS_IRENDERING_CONTEXT_IID \

{ 0x37762dd8, 0x8df0, 0x48cd, \

  { 0xa5, 0xd6, 0x24, 0x57, 0x3f, 0xfd, 0xb5, 0xb6 } }

which does not mean anything to me.

other example, that also do not work with minefield: http://www.c3dl.org/

Official word: https://wiki.mozilla.org/Canvas:3D


Woot! Got Canvas3D to create a buffer! (I got distracted by NPR's telling of the ADM price-fixing story, sorry).

Okay, the relevant/revelatory code can be seen at:

http://mxr.mozilla.org/mozilla-central/source/content/html/c...

Here's the string being constructed in the getContext method, after some checking:

  nsCString ctxString("@mozilla.org/content/canvas-rendering-context;1?id=");
  ctxString.Append(ctxId);
Where ctxId is, say, "2d".

I'd assume it's some kind of resource naming convention or somesuch ... but, anyway, searching for strings "@mozilla.org/" and canvas and gl ...

You get nsLayoutModule.cpp

  ...
  { "Canvas WebGL Rendering Context",
    NS_CANVASRENDERINGCONTEXTWEBGL_CID,
    "@mozilla.org/content/canvas-rendering-context;1?id=moz-webgl",
    CreateCanvasRenderingContextWebGL },
  ...
bingo! "moz-webgl" WORKS.

The first example I tried fails:

  gl.clearDepth is not a function.
:(

But, anyway, it's a start.


Try using "for in" to iterate through the returned canvas's properties. You'll get all the methods of the canvas. So far this sort of stuff works (OSX Leopard): gl.clearColor(0,0,0,0); gl.clear(gl.COLOR_BUFFER_BIT);


Do their forums even work for you?

I just got back, and I'm needing to look at the google cache of almost every mozilla forum page; I haven't gotten through to their forums a single time yet.

Their 'search moz code' thingy still works -- searching it for WebGL turns up lots ... I mean LOTS ... of code. But even though I've found a list of enums for contexts, etc, I still haven't quite found where the mapping is, or where the actual base getcontext() function is located.

I have powerful procrastination forces pushing me, though.


Interesting, but not much use until somebody writes some demo pages to show it off.



Does the FF nightly work for you? It doesn't for me at the moment, at least not with those samples (link to my post below, in case this discussion gets big: http://news.ycombinator.com/item?id=831988).

Any tips appreciated. I'll have a few hours free this afternoon, so I may muck around with this!


I'm interested in why it's not working on for me.

I'll edit this to update on problems as they come. For people trying to run the existing webgl samples (using something like utils3d.js) that are out there with the nightly ff build:

  1) canvasElement.getContext("moz-webgl"), not "webkitwhatever"
(Conflicts w/presentation slides pdf on the khronos site, which says "3D" with a capital D)

  2) context.clearDepth(...) -> .clearDepthf(...)
  3) CanvasFloatArray        -> WebGLFloatArray
That's how far I've gotten so far. Much more perplexing to me is a case where their code seems (I want to stress, seems!; maybe it's staring me in the face and I just don't get how they changed it) to break an opengl function: glBindBuffer. http://www.opengl.org/sdk/docs/man/xhtml/glBindBuffer.xml

The specs say, call glBindBuffer with (arg, arg2), and arg2 will be an unsigned int which refers to a buffer.

The reference above says, calling it with an arg2 of 0 and it'll reset. The webkit examples use it this way. But, their implementation of the wrapped BindBuffer method doesn't like this; if you pass in 0, it gives you an error that suggests you mean null. Pass in null, and there's an uncaught exception and an error in glBufferData, telling you that, surprise, you want an Unsigned Short.

In their code,

  NS_IMETHODIMP
  WebGLContext::BindBuffer(GLenum target, nsIWebGLBuffer *buffer)
  {
    WebGLBuffer *wbuf = static_cast<WebGLBuffer*>(buffer);
    ...
The typing of the args won't let you pass in a zero, and the typing on the constructor for the cast is what kills it if you pass in a javascript null (it wants an integer).

And if you try to instantiate a WebGLBuffer instance with javascript -- whose constructor expects an int -- it won't let you.

  nbuf = new WebGLBuffer(0);
  -> [Exception... "Cannot convert WrappedNative to function"...
You could try calling glGet... on the buffer early on, caching the default value it returns to you and then using that to invoke bindBuffer (just to be sure you're not calling it with something it shouldn't understand) but this doesn't wrap opengl directly enough; it's just whatever you see implemented here (http://mxr.mozilla.org/mozilla-central/source/content/canvas...). Some functions, like bindbuffer, are implemented. The others are named very differently, and look like this:

  NS_IMETHODIMP
  WebGLContext::GetCurrentArrayBufferBinding(nsIWebGLBuffer **aCurrentArrayBufferBinding)
  {
    return NS_ERROR_NOT_IMPLEMENTED;
  }
Heh. Well ... I guess I'll see if I can find an example that never needs to reset the buffer binding. :P




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: