[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] Null return values from create*





On Fri, Apr 13, 2012 at 7:10 PM, Glenn Maynard <glenn@zewt.org> wrote:
On Fri, Apr 13, 2012 at 8:30 PM, Kenneth Russell <kbr@google.com> wrote:
The set of functions where non-nullability could be enforced is only a
small percentage of the WebGL API.

There's nothing inconsistent about functions for which null is *always* a programming error raising TypeError.

Further, there were only
three functions -- bufferSubData, texImage2D and texSubImage2D --
where enforcing non-nullable "data" arguments was under consideration.

No, it's much more than that.  The following functions should have non-nullable arguments:

    void attachShader(WebGLProgram? program, WebGLShader? shader);
    void detachShader(WebGLProgram? program, WebGLShader? shader);
    void bindAttribLocation(WebGLProgram? program, GLuint index, DOMString name);
    WebGLActiveInfo? getActiveAttrib(WebGLProgram? program, GLuint index);
    WebGLActiveInfo? getActiveUniform(WebGLProgram? program, GLuint index);
    WebGLShader[]? getAttachedShaders(WebGLProgram? program);
    any getProgramParameter(WebGLProgram? program, GLenum pname);
    DOMString? getProgramInfoLog(WebGLProgram? program);
    any getUniform(WebGLProgram? program, WebGLUniformLocation? location); (first argument)
    WebGLUniformLocation? getUniformLocation(WebGLProgram? program, DOMString name);
    void linkProgram(WebGLProgram? program);
    void validateProgram(WebGLProgram? program);
    void compileShader(WebGLShader? shader);
    any getShaderParameter(WebGLShader? shader, GLenum pname);
    DOMString? getShaderInfoLog(WebGLShader? shader);
    DOMString? getShaderSource(WebGLShader? shader);
    void shaderSource(WebGLShader? shader, DOMString source);
    GLint getAttribLocation(WebGLProgram? program, DOMString name);
    void bufferData(GLenum target, ArrayBuffer? data, GLenum usage);
    void bufferSubData(GLenum target, GLintptr offset, ArrayBuffer? data);

and the following should have non-nullable return values (I havn't seen any rationale for why this hasn't been done; it's worthwhile on its own):

    WebGLBuffer? createBuffer();
    WebGLFramebuffer? createFramebuffer();
    WebGLProgram? createProgram();
    WebGLRenderbuffer? createRenderbuffer();
    WebGLShader? createShader(GLenum type);
    WebGLTexture? createTexture();

(The delete* and is* functions should have simply been two member functions on WebGLObject, "delete()" and "isValid()", but it's too late to fix that...)

The MO of the WebGL group is to bring OpenGL ES 2.0 to the Web. Not design some new API.

Honestly, I agree with you. I'd much prefer program.delete() and program.isValid() as well as program.getUniformLocation(). program.attachShader() and program.getInfoLog() etc..

I'd even prefer 

   tex = gl.createTexture(gl.TEXTURE_2D)

and then from that point on

   tex.image2D(....);
   tex.parameter(...);

but several others would like the API to stay as close to OpenGL as possible and so for the most part it has.



 


--
Glenn Maynard