On 2014-05-07, 6:15 AM, Anne van Kesteren wrote:
WebGL is already following the OpenGL path.  Trying to make it more "webby" by 
trying to mush the APIs together isn't doing the web a favor since the API is already 
more OpenGL-like, isn't doing developers a favor since they now have to have this pile of 
getExtension() code around, and is definitely not doing us a favor, because we have to 
support the explosion of all combo of extensions.

Again, this seems like a false comparison. No need for an explosion of
extensions. Furthermore, what you're advocating will give us an
enormous API surface area long term, which we'll have to maintain and
test, even though most new content will not use it (they'll get the
newer classes).

So earlier I suggested feature detecting based on _a_ new WebGL2 feature, to which Benoit replied that is a bad idea since your code would be testing something and assuming unrelated support of other features based on that (which _is_ bad practice, but I thought is a goal of the all-or-nothing approach of the WebGL2 API.)

So in response, I suggested making individual features feature detectible (which is totally doable in your FOO/FROB/BLARG example BTW!) to which you replied saying that is a bad idea since all of the features are either supported or not (if I understand your response correctly.)

I think one possible middle ground would be to define the API as follows:

interface WebGL2RenderingContext : WebGLRenderingContext {
  // new methods go here
};

partial interface HTMLCanvasElement {
  (CanvasRenderingContext2D or
   WebGLRenderingContext or
WebGL2RenderingContext) getContext(DOMString id, optional any options = null);
};

And keep the string "webgl" as the name of the context. This way, Web content can do the following checks:

if (window.WebGL2RenderingContext) {
  // this browser supports the WebGL2 APIs
}

var ctx = canvas.getContext("webgl");

if (ctx instanceof WebGL2RenderingContext) {
  // I actually got a WebGL2 context, my hardware also supports it!
}

This will preserve the all-or-nothing-ness of the WebGL2 feature set, it will not require maintaining different code paths depending on which set of individual extensions are enabled, is completely forward/backward compatible, and at least limits the API surface that we will need to support forever.

What do you think?

Cheers,
Ehsan
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to