Skip to content

Commit

Permalink
Deploying to gh-pages from @ 9044129 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
greggman committed Mar 8, 2024
1 parent a29c4ec commit f316b00
Show file tree
Hide file tree
Showing 9 changed files with 2,915 additions and 1 deletion.
8 changes: 8 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,13 @@ var resizeCanvas = {
],
};

var resizeObserverHDDPI = {
name: 'ResizeObserver HD-DPI Fullscreen',
description: `This example shows how to use ResizeObserver, handle HD-DPI correctly, and Fullscreen`,
filename: "sample/resizeObserverHDDPI",
sources: [{ path: 'main.ts' }, { path: 'checker.wgsl' }],
};

var reversedZ = {
name: 'Reversed Z',
description: `This example shows the use of reversed z technique for better utilization of depth buffer precision.
Expand Down Expand Up @@ -538,6 +545,7 @@ const pageCategories = [
description: 'Demos integrating WebGPU with other functionalities of the web platform.',
samples: {
resizeCanvas,
resizeObserverHDDPI,
videoUploading,
worker,
},
Expand Down
2 changes: 1 addition & 1 deletion main.js.map

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions sample/resizeObserverHDDPI/checker.wgsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
struct Uniforms {
color0: vec4f,
color1: vec4f,
size: u32,
};

@group(0) @binding(0) var<uniform> uni: Uniforms;

@vertex
fn vs(@builtin(vertex_index) vertexIndex : u32) -> @builtin(position) vec4f {
const pos = array(
vec2f(-1.0, -1.0),
vec2f( 3.0, -1.0),
vec2f(-1.0, 3.0),
);
return vec4f(pos[vertexIndex], 0.0, 1.0);
}

@fragment
fn fs(@builtin(position) position: vec4f) -> @location(0) vec4f {
let grid = vec2u(position.xy) / uni.size;
let checker = (grid.x + grid.y) % 2 == 1;
return select(uni.color0, uni.color1, checker);
}

36 changes: 36 additions & 0 deletions sample/resizeObserverHDDPI/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>webgpu-samples: resizeObserverHDDPI</title>
<style>
html, body {
margin: 0; /* remove default margin */
height: 100%; /* make body fill the browser window */
}
canvas {
width: 100%;
height: 100%;
display: block;
}
.fit-container {
width: 100%;
height: 100%;
}
.resizable {
resize: both;
overflow: scroll; /* required because resize doesn't work with overflow: visible, the default */
max-width: 100%;
max-height: 100%;
}
</style>
<script defer src="main.js" type="module"></script>
<gscript defer type="module" src="../../js/iframe-helper.js"></script>
</head>
<body>
<div id="container" class="fit-container">
<canvas></canvas>
</div>
</body>
</html>
Loading

0 comments on commit f316b00

Please sign in to comment.