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

[Public WebGL] isBuffer, isTexture etc.



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"