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

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



The issue with adding them to the main spec is there's no good way to check for them

if (gl.texImage2D) //  always true

You'd have to do something really ugly like

try {
  gl.texImage2D(args that use src rect);
} catch (e) {
  // remember that texImage2D with src rect option does not exist 
}






On Fri, Jul 20, 2012 at 1:46 AM, Marco Di Benedetto <[email protected]> wrote:
The idea of an extension sounds good.
However, considering that the two new functions would practically have
zero impact on the implementation (apart from region clipping / error
generation), I would dare to insert them in the specifications.
Actually, rather than adding them, I would modify the existing ones
(aaarghhh, backward compatibility issue!) with the more flexible ones.

m.



On Fri, Jul 20, 2012 at 3:07 AM, Ben Vanik <[email protected]> wrote:
> correct - and yeah, a WEBGL_texture_element_subregion or something would be
> fine
>
>
> On Thu, Jul 19, 2012 at 5:43 PM, Gregg Tavares (社用) <[email protected]> wrote:
>>
>> Would this be ok as an extension? That seems best since there's no easy
>> way to check for it's existence if its on the main context (short of
>> try/catch/pray)
>>
>> Basically it seems like you'd want
>>
>>   texImage2D(target, level, internalFormat, srcx, srcy, width, height,
>> format, type, element);
>>   texSubImage2D(target, level, srcx, srcy, dstx, dsty, width, height,
>> format, type, element);
>>
>>
>>
>>
>> On Thu, Jul 19, 2012 at 3:00 PM, Ben Vanik <[email protected]> wrote:
>>>
>>> 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
>>> <[email protected]> wrote:
>>>>
>>>>
>>>> Hi,
>>>>
>>>> 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) ?
>>>>
>>>> Thanks,
>>>> m.
>>>>
>>>>
>>>>
>>>> --
>>>> 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: [email protected] - [email protected]
>>>>
>>>> -----------------------------------------------------------
>>>> You are currently subscribed to [email protected].
>>>> To unsubscribe, send an email to [email protected] with
>>>> the following command in the body of your email:
>>>> unsubscribe public_webgl
>>>> -----------------------------------------------------------
>>>>
>>>
>>
>



--
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: [email protected] - [email protected]