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

Re: [Public WebGL] isBuffer, isTexture etc.

On Thu, Apr 22, 2010 at 3:47 PM, Chris Marrin <cmarrin@apple.com> wrote:

On Apr 22, 2010, at 10:45 AM, Gregg Tavares wrote:

> So it apparently turns out that the namespaces for GL objects are not shared.
> In other words,  glIsBuffer does not tell you whether or not some name is a buffer. It tells you whether or not a buffer exists with a specific id.  The difference is subtle but what it means is 2 resources of different types can have the same name.
> Try this out in C
> glBindBuffer(GL_ARRAY_BUFFER, 1);
> glBindTexture(GL_TEXTURE_2D, 1);
> printf ("is buffer: %d\n", glIsBuffer(1));   // prints 1
> printf ("is texture: %d\n", glIsTexture(1));  // prints 1
> That means the following WebGL functions
>     GLboolean isBuffer(in WebGLObject buffer) raises(DOMException);
>     GLboolean isFramebuffer(in WebGLObject framebuffer) raises(DOMException);
>     GLboolean isProgram(in WebGLObject program) raises(DOMException);
>     GLboolean isRenderbuffer(in WebGLObject renderbuffer) raises(DOMException);
>     GLboolean isShader(in WebGLObject shader) raises(DOMException);
>     GLboolean isTexture(in WebGLObject texture) raises(DOMException);
> Should be changed to take their respective types as in
>     GLboolean isBuffer(in WebGLBuffer buffer) raises(DOMException);
>     GLboolean isFramebuffer(in WebGLFramebuffer framebuffer) raises(DOMException);
>     GLboolean isProgram(in WebGLProgram program) raises(DOMException);
>     GLboolean isRenderbuffer(in WebGLRenderbuffer renderbuffer) raises(DOMException);
>     GLboolean isShader(in WebGLShader shader) raises(DOMException);
>     GLboolean isTexture(in WebGLTexture texture) raises(DOMException);
> In the WebGL case they would only return false after delete has been called for the particular object.
> Example
>     var t = ctx.createTexture();
>     console.log (ctx.isTexture(t));  // prints "true"
>     ctx.deleteTexture(t);
>     console.log (ctx.isTexture(t));  // prints "false"

Yes, I see where the OpenGL definition is different than what we've been assuming. But I'm note sure we should change the API. If we leave it as is, the functions will perform as you say. A deleted object will return false. But it will also perform the additional task of type checking. So you can ask, "is this object a valid FrameBufferObject?" which will only return true if the object is actually a FrameBufferObject AND it hasn't been deleted. That seems like useful and non-harmful functionality.

Except it's duplicated. You can already check the type of an object in language standard ways can't you?

if (myObject instanceof WebGLTexture) { ... }



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