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

Re: [Public WebGL] Should texSubImage2D accept null like texImage2D does?

May I suggest that while modifying the signatures of these methods in future versions that they be widened to support taking ArrayBuffer as well? For those of us using XHR/File APIs that return ArrayBuffers or pass around ArrayBuffers in our code it's often a waste to have to wrap everything in a Uint8Array/etc before calling these methods - especially when the implementations don't need the type from the view.

On Tue, Mar 13, 2012 at 4:13 PM, Kenneth Russell <kbr@google.com> wrote:

On Tue, Mar 13, 2012 at 12:47 PM, Gregg Tavares (勤) <gman@google.com> wrote:
> On Tue, Mar 13, 2012 at 9:33 AM, Glenn Maynard <glenn@zewt.org> wrote:
>> On Tue, Mar 13, 2012 at 10:58 AM, Tim Johansson <timj@opera.com> wrote:
>>> For example validateProgram and useProgram both take WebGLProgram but
>>> have to accept null to pass the conformance tests IIRC. In the case of
>>> validateProgram it should give you INVALID_VALUE and in the case of
>>> useProgram it should actually do something (unbind the current program).
>> The conformance test is incorrect; validateProgram(null) should throw
>> TypeError.  (Since the WebGL spec doesn't correctly use nullable parameters,
>> it's not too surprising if the tests get them wrong, too.)
> I think it comes down to emulating OpenGL or not. glValidateProgram excepts
> 0 will generate INVALID_VALUE therefore it's not unreasonable for WebGL to
> do the same. I don't expect any programs use validateProgram but the idea is
> that OpenGL programs should be portable to WebGL with as few changes as
> possible.
> glTexSubImage2D if passed null will crash if all other parameters are valid.
> Therefore throwing an exception if passed null OpenGL seems more acceptable.
> On the the other hand, calling
>    GLint width = 0;
>    GLint height = 0;
>    glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_RGBA,
> will likely not crash since no data will be referenced.

In general we should fix the issues with nullable arguments in the WebGL spec.

This will be a large change. I suggest that we do this in the current
editor's draft and conformance tests, and leave the currently
ill-specified behavior untested in the 1.0.1 conformance tests.

For the particular case of texSubImage2D taking ArrayBufferView, I'm
more in favor of forcing the argument to be non-nullable so that the
type system catches the error.


>> useProgram's parameter should be nullable, of course.
>> --
>> Glenn Maynard

You are currently subscribed to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email:
unsubscribe public_webgl