Microsoft/TypeScript

texSubImage2D missing WebGL2 syntax

Open

#58,695 opened on May 29, 2024

View on GitHub
 (0 comments) (0 reactions) (0 assignees)TypeScript (6,726 forks)batch import
BugDomain: lib.d.tsHelp Wanted

Repository metrics

Stars
 (48,455 stars)
PR merge metrics
 (Avg merge 6d 17h) (9 merged PRs in 30d)

Description

🔎 Search Terms

texSubImage2D WebGL2

🕗 Version & Regression Information

  • I was unable to test this on prior versions because I used gl.texSubImage2D with ImageBitmap as source only just now

⏯ Playground Link

No response

💻 Code

gl.texSubImage2D(
  gl.TEXTURE_2D,
  0,
  0,
  0,
  100,
  100,
  gl.RGBA,
  gl.UNSIGNED_BYTE,
  data // <----- instanceof ImageBitmap
);

🙁 Actual behavior

Error:

Argument of type 'ImageBitmap' is not assignable to parameter of type 'ArrayBufferView'. Type 'ImageBitmap' is missing the following properties from type 'ArrayBufferView': buffer, byteLength, byteOffset

🙂 Expected behavior

The code actually works fine, but I expect TS to not complain about the type.

Additional information about the issue

I am using a worker to gradually create the texture by creating the tiles and sending them back. The data comes from createImageBitmap metod as ImageBitmap and then pass it to texSubImage2D

Contributor guide