WebGL2RenderingContext: phương thức texStorage2D()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2021.

Note: This feature is available in Web Workers.

Phương thức texStorage2D() của WebGL2RenderingContext trong WebGL API chỉ định tất cả các mức của lưu trữ texture hai chiều.

Cú pháp

js
texStorage2D(target, levels, internalformat, width, height)

Tham số

target

Một GLenum chỉ định điểm liên kết (target) của texture đang hoạt động. Các giá trị có thể:

  • gl.TEXTURE_2D: Texture hai chiều.
  • gl.TEXTURE_CUBE_MAP: Texture cube-map.
levels

Một GLint chỉ định số mức texture.

internalformat

Một GLenum chỉ định định dạng lưu trữ texture.

width

Một GLsizei chỉ định chiều rộng của texture tính bằng texel.

height

Một GLsizei chỉ định chiều cao của texture tính bằng texel.

Giá trị trả về

None (undefined).

Ví dụ

js
gl.texStorage2D(gl.TEXTURE_2D, 1, gl.RGB8, 256, 256);

Đặc tả kỹ thuật

Specification
WebGL 2.0 Specification
# 3.7.6

Tương thích trình duyệt

Xem thêm