Creating texture from getImageData (Javascript)

后端 未结 3 1690
谎友^
谎友^ 2021-01-23 16:18

It is possibile to create a texture (to use on a element in a canvas) from the getImageData array of another canvas (in the same html page)? maybe without three.js? Thanks a lot

3条回答
  •  再見小時候
    2021-01-23 17:20

    Yes, texImage2D can take an ImageData.

    var imageData = some2DCanvasContext.getImageData(...);
    gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, imageData);
    

    Here are is one of the WebGL conformance tests that test this functionality

    https://www.khronos.org/registry/webgl/sdk/tests/conformance/textures/tex-image-and-sub-image-2d-with-image-data.html

提交回复
热议问题