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

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



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,
> GL_UNSIGNED_BYTE, NULL);
>
> 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.

-Ken


>>
>>
>> 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
-----------------------------------------------------------