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

Re: [Public WebGL] 2d canvas context to WebGL



FWIW, Construct 2 uses texImage2D with a 2D canvas to render text. Since WebGL doesn't have built-in text rendering, rendering text to a 2D canvas then copying it to a WebGL texture can be useful (note DOM text doesn't allow you to draw over text or process text effects in the WebGL context). If the text content changes every frame, it has to call texImage2D with a 2D canvas every frame. I don't think many games are realistically bottlenecked on that and it's fairly easy to work around, but it's a major use case for that particular overload.

Ashley Gullen
Scirra.com



On 24 April 2013 21:47, Benoit Jacob <bjacob@mozilla.com> wrote:

A 2D canvas can be passed directly to WebGL texImage2D.

This happens to be slow in Firefox at the moment (the canvas is
currently read back and re-uploaded), but that could probably be fixed
if there is real-world pressure in that direction.

Benoit

On 13-04-24 04:23 PM, Rik Cabanier wrote:
> All,
>
> Sorry if this is already documented but is there a way to efficiently
> use a 2d canvas context in WebGL?
> We've seen cases where people want to apply effects on 2d contexts and
> they're doing this by copying the 2d canvas to a buffer, running a
> shader on it and getting the result back.
> This is an expensive workflow both in time and memory.
>
> Since the 2d canvas is already on the GPU (on most browsers), is there
> a way to directly access it from WebGL?
>
> Thanks!


-----------------------------------------------------------
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
-----------------------------------------------------------