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

Re: [Public WebGL] isBuffer, isTexture etc.



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.
Alternatively the implementation could just do a type check ("am i a GLBuffer?" etc) before extracting the resource name.  By changing to an explicit type you're more or less ensuring that will happen anyway.

> 
> 
> Example
> 
>     var t = ctx.createTexture();
>     console.log (ctx.isTexture(t));  // prints "true"
>     ctx.deleteTexture(t);
>     console.log (ctx.isTexture(t));  // prints "false"
> 
> 


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