stackgl / headless-gl

🎃 Windowless WebGL for node.js
1.73k stars 166 forks source link

gl.texImage2D and HTMLCanvasElement #257

Open stepancar opened 1 year ago

stepancar commented 1 year ago

Hello! gl.texImage2D supports HTMLCanvasElement

In browser it works instantly , because under the hood they avoid moving data GPU -> CPU -> GPU

In headless gl implementation we see that in order to upload canvas to webgl it reads pixels from 2d context and then uploads it webgl

https://github.com/stackgl/headless-gl/blob/f1ed92fef1688bd9e9b8206516d1083a186f7ce3/src/javascript/webgl-rendering-context.js#L3149

Is it possible to speed it up somehow using just webgl?

stepancar commented 1 year ago

@ivanpopelyshev maybe you can suggest anything, thanks!

stepancar commented 1 year ago

If I understand correctly, we could create shared textures using EGL and pass them between contexts