[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 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...)

--
Glenn Maynard