0

I'm trying to convert my code from WebGL to WebGPU. In WebGL, I'm using below code to update pixel Image data to update in canvas.

....
    var texture = webglCtx.createTexture();
    webglCtx.bindTexture(webglCtx.TEXTURE_2D, texture);

    webglCtx.texParameteri(webglCtx.TEXTURE_2D, webglCtx.TEXTURE_MIN_FILTER, webglCtx.NEAREST);
    webglCtx.texParameteri(webglCtx.TEXTURE_2D, webglCtx.TEXTURE_MAG_FILTER, webglCtx.NEAREST);
    webglCtx.texParameteri(webglCtx.TEXTURE_2D, webglCtx.TEXTURE_WRAP_S, webglCtx.CLAMP_TO_EDGE);
    webglCtx.texParameteri(webglCtx.TEXTURE_2D, webglCtx.TEXTURE_WRAP_T, webglCtx.CLAMP_TO_EDGE);     

    webglCtx.texImage2D(webglCtx.TEXTURE_2D, 0, webglCtx.RGBA, webglCtx.RGBA, webglCtx.UNSIGNED_BYTE, image);
    webglCtx.drawArrays(webglCtx.TRIANGLES, 0, 6);

How can I convert this for WebGPU? Appreciate your help.

Note: image is ImageData

Joe
  • 365
  • 2
  • 9
  • 24
  • Maybe you'd find [this article](https://webgpufundamentals.org/webgpu/lessons/webgpu-importing-textures.html) useful – gman Jul 15 '23 at 04:40

0 Answers0