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

Re: [Public WebGL] specify a source rectangle from HTMLElement to texture

I too would like this ability, and it feels like it was an oversight in the spec.

My primary use case is having a <canvas> that has dynamic content of differing sizes drawn to it (in this case, text strings) and uploaded to textures repeatedly over the course of an application run. Currently I have to pool canvases of varying sizes to try to approximate the right size when uploading and prevent waste, but it'd be much simpler, faster, and more memory efficient to be able to just subset a single canvas.

On Thu, Jul 19, 2012 at 2:48 PM, Marco Di Benedetto <marco.dibenedetto@isti.cnr.it> wrote:


I am sorry for posting this stuff again, but I had no feedback from
this mailing list (I don't know if it was my mailserver issue...).
A copy of my original post follows (original post subject was:
Specifying source rectangle in texImage2D and texSubImage2D overloads
with HTML elements).

According to the specifications (well, actually inferring it from the
API), the overload versions of texImage2D and texSubImage2D taking an
HTMLElement (canvas/image/video) extract the image/subimage dimensions
from the element itself.
It would be useful if a source subrectangle (both origin and
dimensions) could be specified, more or less as the ArrayBufferView
overloads do.

I know there are several ways to accomplish this, like rendering the
subrect on a canvas and read it back (with ImageData maybe...), or
creating a full-sized intermediate texture to be used as source and
then manually render the subrect to another texture, or whatever else.
Anyway, these methods involve an unnecessary copy.

Am I unaware of some JS API that extract an ImageData subrect from
images/videos without passing through a canvas (even if, to my
intuition, this is also sub-optimal) ?
I could understand that compression issues may force the decompression
of the whole image/frame before extracting a subrect, but still,
native code doing this would perform better.

Or is there already something to do this "ideal" subrect transfer
(shame on me, I didn't found it) ?


Marco Di Benedetto, Ph.D.

Researcher at the Visual Computing Lab
Istituto di Scienza e Technologie dell'Informazione "A. Faedo" (ISTI)
Consiglio Nazionale delle Ricerche (CNR) - Pisa - Italy
Office Phone: +39 050 315 2921
E-Mail: marco.dibenedetto@isti.cnr.it - spattija@gmail.com

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:
unsubscribe public_webgl