Search code examples
webglangle

WebGL: Asynchronous texImage2D?


I am updating some textures of the scene all the time by new images. Problem is uploading is synchronous and texImage2D takes ~100ms. It takes so long time even if texture is not used during rendering of the next frame or rendering is switched off.

I am wondering, is there any way to upload texture data asynchronously?

Additional conditions:

I had mention there is old texture which could stay active until uploading of new one to GPU will be finished.


Solution

  • Solution is to use texSubImage2D and upload image to GPU by small portions. Once uploading will be finished activate your new texture and delete old one.