[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 <email@example.com>
On Fri, Apr 13, 2012 at 8:30 PM, Kenneth Russell <firstname.lastname@example.org>
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):
WebGLShader? createShader(GLenum type);
(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
but several others would like the API to stay as close to OpenGL as possible and so for the most part it has.