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

[Public WebGL] WebGLExtension interface proposal



Hi,

We specify extensions as objects with more or less the same behavior as other WebGL objects mapped to GL resources, ie. an extensions object is only valid for use by the WebGLRenderingContext who created it and they should be re-created after context is lost ; as such I believe it would make sense to declare a WebGLExtension interface from which all WebGL extensions must derive.
It could simplify implementations (can use the same base WebGLObject implementation for validation/tracking, extensions could also more easily use same base object for internal housekeeping), but more importantly it makes API friendlier to more strongly-typed languages (versus 'object'), avoids potential 'empty object extension' which might be confusing, and allows us to transparently add new 'utility' members on all extensions if we need to do so in a future revision.

In other words, I propose following spec addition :


5.XX WebGLExtension

The WebGLExtension interface represents an extension object. All WebGL extensions derive from this interface.
The object is returned by calling getExtension with a supported extension string (see 5.16.14 Detecting and enabling extensions).

interface WebGLExtension : WebGLObject {
readonly attribute DOMString name;
}


And :

WebGLExtension getExtension(DOMString name);

instead of :

object getExtension(DOMString name);



Finally, for consistency with other WebGLObjects I propose introduction of an isExtension function to check if an extension
object is valid (ie. not obtained from another context and not acquired before context loss) :

GLboolean isExtension(WebGLExtension extension);



Possibly we might as well simplify API and merge all is* functions into only one, e.g a probably better named "GLboolean isValid(WebGLObject object)".
(all current is* functions can trivially be wrapped to use it in _javascript_ so there is no feature removal and/or divergence imho)


Thoughts?


Regards,