A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.cdn.mozilla.net/en-US/docs/Web/API/GPURenderPassEncoder/setViewport below:

GPURenderPassEncoder: setViewport() method - Web APIs

GPURenderPassEncoder: setViewport() method

Limited availability

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Note: This feature is available in Web Workers.

The setViewport() method of the GPURenderPassEncoder interface sets the viewport used during the rasterization stage to linearly map from normalized device coordinates to viewport coordinates.

Syntax
setViewport(x, y, width, height, minDepth, maxDepth)
Parameters
x

A number representing the minimum X value of the viewport, in pixels.

y

A number representing the minimum Y value of the viewport, in pixels.

width

A number representing the width of the viewport, in pixels.

height

A number representing the height of the viewport, in pixels.

minDepth

A number representing the minimum depth value of the viewport.

maxDepth

A number representing the maximum depth value of the viewport.

Note: If a setViewport() call is not made, the default values are (0, 0, attachment width, attachment height, 0, 1) for each render pass.

Return value

None (Undefined).

Validation

The following criteria must be met when calling setViewport(), otherwise a GPUValidationError is generated and the GPURenderPassEncoder becomes invalid:

Note: See the color and depth/stencil attachments specified in the descriptor of GPUCommandEncoder.beginRenderPass(); the width and height are based on that of the GPUTexture that their views originate from.

Examples Basic snippet

In a typical canvas render, the following could be used to halve the width and height of the rendered graphics:

passEncoder.setViewport(0, 0, canvas.width / 2, canvas.height / 2, 0, 1);
In context

In the WebGPU Samples reversedZ example, setViewport is used several times to set the viewport for the different render passes. Study the example code listing for the full context.

For example:

// …

colorPass.setViewport(
  (canvas.width * m) / 2,
  0,
  canvas.width / 2,
  canvas.height,
  0,
  1,
);

// …
Specifications Browser compatibility See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4