[Public WebGL] y-orientation for texImage2D from HTML elements
Thu Dec 6 18:12:41 PST 2012
On 2012/12/07 10:27, Jeff Gilbert wrote:
> It is also a little crazy that texImage2D(gl.canvas) does not reduce to the same operation as copyTexImage2D.
Welcome to the world of bashing square pegs into round holes.
> I understand that people are used to passing image data directly to texImage2D as top-row-first, and just dealing with the flipped u/v coords, but this choice should not be force on everyone as it is now. UNPACK_FLIP_Y_WEBGL as it is today does not solve this, as to get consistent bottom-row-first behavior, an app needs to use UNPACK_FLIP_Y_WEBGL=false for TypedArray uploads, and UNPACK_FLIP_Y_WEBGL=true for HTML element uploads.
Why should we try to hide that HTML elements have a top-left,
top-row-first origin? It is easy enough for the application to change
the setting of UNPACK_FLIP_Y_WEBGL between uploading from a typed array
and uploading from an HTML element.
> WebGL is *not* working the same way as OpenGL here, because OpenGL *only* accepts raw bytes. If you upload data top-row-first, and use uv 0,0 at the top-left, it's right-side-up. If you upload data bottom-row-first (like the texImage2D spec says), and use uv 0,0 at the bottom-left, it's also right-side-up. WebGL introduces loading from images directly.
WebGL works exactly the same way as OpenGL. As in WebGL the application
is expected to understand that most image formats have a top-left origin
and to flip the data before uploading or provide different texture
coordinates. WebGL provides the service of decoding and uploading
standard image formats so we provided the pixel store property to
request a flip. The knowledge needed by an application developer is the
same in both cases.
> This means WebGL has to make a choice over what order to upload the rows. Whereas texImage2D on TypedArrays doesn't really matter,
We made a choice that WebGL would not make a choice. The application
specifies whether it wants the image flipped or not. If it doesn't and
wants the image the right way up, it is expected to supply the necessary
> texImage2D on HTML elements can't automatically handle both. We have half the solution in the form of UNPACK_FLIP_Y_WEBGL, but it doesn't provide a solution to making WebGL consistent for both choices of origin location.
You've lost me here. What does "texImage2D on HTML elements can't
automatically handle both" mean? Do HTML elements come with different
orientations? I thought they were all top-left therefore why does
texImage2D on HTML elements need to handle both?
NOTE: This electronic mail message may contain confidential and
privileged information from HI Corporation. If you are not the intended
recipient, any disclosure, photocopying, distribution or use of the
contents of the received information is prohibited. If you have received
this e-mail in error, please notify the sender immediately and
permanently delete this message and all related copies.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the public_webgl