Hacker News new | past | comments | ask | show | jobs | submit login

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



Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: