Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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);




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: