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

Re: [Public WebGL] INVALID_VALUE or INVALID_OPERATION for bad object args



On Thu, Jun 3, 2010 at 11:05 AM, Vladimir Vukicevic
<vladimir@mozilla.com> wrote:
> For various GL calls that take GL object names as arguments, e.g. LinkProgram, they can generate two distinct errors in case a somehow "wrong" object is passed:
>
>  GL_INVALID_VALUE is generated if program is not a value generated by OpenGL.
>
>  GL_INVALID_OPERATION is generated if program is not a program object.
>
> We don't really have this distinction in WebGL, and I'm not sure what the right error to raise is here.  I'm interpreting this to mean, for WebGL:
>
>  GL_INVALID_VALUE is generated if the given program was not created by this WebGL context.
>
>  GL_INVALID_OPERATION is generated if the program is not a program object.
>
> Does that sound right?

Because e.g. LinkProgram takes a WebGLProgram as an argument, Web IDL
defines the behavior when a value not compatible with WebGLProgram is
passed: a TypeError is raised.

http://dev.w3.org/2006/webapi/WebIDL/#es-interface

Therefore the cases that need to generate OpenGL errors are:
 1. Passing null when a non-null object is required.
 2. Passing an object created by another context.
 3. Passing an object which has been explicitly deleted.

It seems to me that the first case, passing a null value when a
non-null one is required, should generate INVALID_VALUE, since null is
never a valid value for such functions. In the second, though, I think
INVALID_OPERATION should be generated. The reason is that in a future
version of the WebGL spec we expect to support sharing of resources
between contexts, so in some situations (when the two contexts are
sharing resources) a given value would be valid, and in other
situations (when the two contexts don't share resources) it would be
invalid. Because the value wouldn't always be invalid,
INVALID_OPERATION seems to be the right error to generate. In the
third case, since the object was once valid, INVALID_OPERATION again
seems like the right choice.

-Ken

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