On May 19, 2010, at 10:36 AM, Gregg Tavares wrote:
> ...I'm not sure how it's any more alien than flipy and premultipliedAlpha. We might as well argue that naming these functions texImage2D is inappropriate. Perhaps it would be better to have conversion functions that take in one of the image element types and the convertTo, flipy and premultipliedAlpha params and return a filled in ArrayBuffer. I don't particularly like that idea because it would not allow optimizations that might be possible on some platforms, such as directly writing the image to GPU memory using some non-OpenGL mechanism.
>First, let me note that these formats are not supported in the OpeGL ES 2.0, nor will they be supported in WebGL 1.0.
> Personally I think this is the better solution.
> We're trying to add all kinds of conversion stuff to texImage2D that may or may not make sense.
> How do the types UNSIGNED_SHORT_5_6_5, UNSIGNED_SHORT_4_4_4_4 and UNSIGNED_SHORT_5_5_5_1 fit into these conversions? For example one of the arguments for supporting conversion to LUMINANCE and ALPHA formats was space savings but if that's the argument for supporting conversions then it applies to these types as well.
> It really seems all this conversion belongs outside of texImage2D. add ArrayBuffer ctx.convertTo(img, format, ....) or something like that.
All of those formats ARE supported in OpenGL ES 2.0 and in WebGL. There are even conformance tests for them.
There's a bigger problem though.
In OpenGL (not ES) the 3 parameters, internalFormat
internalFormat specifies the internal format. The format of the texture texImage2D will create.
format and type specify in source format. The format of the data being passed in to texImage2D.
In OpenGL ES 2.0 these are conflated. type
specifies BOTH the internal and source formats.
To see where this happens see http://www.khronos.org/registry/gles/extensions/OES/OES_texture_float.txt
In OpenGL to make a floating point texture you do
glTexImage2D(GL_TEXURE_2D, level, GL_RGBA32F_ARB, width, height, border, GL_RGBA, GL_UNSIGNED_BYTE, data);
The final format, floating point RGBA is completely separate from the input format.
In OpenGL ES 2.0 though these are conflated. Since it assumes no conversions. To make a floating point texture there you do
glTexImage2D(GL_TEXURE_2D, level, GL_RGBA width, height, border,
GL_RGBA, GL_FLOAT, data);
The OpenGL way is far more flexible than the OpenGL ES way. It seems like we should take some inspiration from there which will leave things open for more conversions such has IMG -> 5_6_5 or IMG->4_4_4_4 etc instead of just IMG to only 8 bit formats.