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

Re: [Public WebGL] Move flipY and asPremultipliedAlpha parameters out of DOM helpers

On Thu, May 20, 2010 at 23:55, Chris Marrin <cmarrin@apple.com> wrote:
> As I pointed out in my previous post, I think adding a general purpose image converter to WebGL would be a really bad idea.
>(...) That's why the conversion should be specific to the functions that take the HTML specific data types.

I agree, the texture parameters proposed here are not general purpose
converters, they specifically have _DOM_ in their name to reflect they
are parameters to be used by WebGL's DOM helpers only.

> What we need is a bridge between what HTML is able to supply and what WebGL needs.

Yes I also agree with that, I only argue that the current API for that
regarding flipy/premultipliedalpha is bad from a readability and
extensibility point of view.

I think we'll all agree at least that boolean parameters are a code
smell when it comes to API design, they should be avoided in all cases
unless behavior of the boolean is obvious (e.g one boolean parameter
for a function named setVisibility). If that's not the case it is
almost always better to use enums instead for both readability and

Consider the current API with that rule in mind :

texImage2D(...img, false, true)  becomes  texImage2D(...img,
texImage2D(...img, true, true)  becomes  texImage2D(...img, gl.FLIP_Y

This is arguably much more readable/maintainable and allows new
options to be added easily if needs be (by core or extensions).

Above is already quite an improvement over the current optional
booleans API, that would be a possible middle ground imho.
Nonetheless I believe texParameter is the next logical step in this
API's improvement since it provides even more advantages : it maps
well to GL's extensibility model [1], allows unlimited extensibility
(i.e bitmasks are complicated when there is more than a few options),
and allows configurable options usable with the same unified model
(e.g texParameterfv(GAMMA_CORRECTION_EXT, [1.8, 2.0, 1.8, .1.0]) ).


[1] : existing GL and ES extensions do provide new tex parameters for
specific purpose, e.g CROP_RECT_OES which works only on the
extension-specific DrawRectOES call ; this is equivalent to say that
FLIP_Y works only on the WebGL-specific DOM helper calls.
You are currently subscribed to public_webgl@khronos.org.
To unsubscribe, send an email to majordomo@khronos.org with
the following command in the body of your email: