deno.com

class GPUTexture

implements GPUObjectBase

Represents a texture (image) in GPU memory.

Examples #

#
// Create a texture to render to
const texture = device.createTexture({
  label: "Output Texture",
  size: { width: 640, height: 480 },
  format: "rgba8unorm",
  usage: GPUTextureUsage.RENDER_ATTACHMENT | GPUTextureUsage.TEXTURE_BINDING,
});

// Get a view of the texture (needed for most operations)
const textureView = texture.createView();

// When the texture is no longer needed
texture.destroy();

// Example: Creating a depth texture
const depthTexture = device.createTexture({
  size: { width: 640, height: 480 },
  format: "depth24plus",
  usage: GPUTextureUsage.RENDER_ATTACHMENT,
});

Properties #

#depthOrArrayLayers: number
readonly
#height: number
readonly
#label: string
#mipLevelCount: number
readonly
#sampleCount: number
readonly
#width: number
readonly

Methods #