Skip to content

Commit

Permalink
Warn when HDR canvas is not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
beaufortfrancois committed Oct 1, 2024
1 parent 268c290 commit a5be0dc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
11 changes: 6 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"@types/showdown": "^2.0.6",
"@types/stats.js": "^0.17.3",
"@typescript-eslint/eslint-plugin": "^7.13.0",
"@webgpu/types": "^0.1.44",
"@webgpu/types": "^0.1.47",
"chokidar": "^3.6.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^8.10.0",
Expand Down
15 changes: 13 additions & 2 deletions sample/particles/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function configureContext() {
toneMapping: { mode: simulationParams.toneMappingMode },
alphaMode: 'premultiplied',
});
updateHdrFolderName();
}

const particlesBuffer = device.createBuffer({
Expand Down Expand Up @@ -347,11 +348,21 @@ hdrFolder.add(simulationParams, 'brightnessFactor', 0, 4, 0.1);
hdrFolder.open();
const hdrMediaQuery = window.matchMedia('(dynamic-range: high)');
function updateHdrFolderName() {
if (!hdrMediaQuery.matches) {
hdrFolder.name = 'HDR settings ⚠️ Your display is not compatible';
return;
}
if (!('getConfiguration' in GPUCanvasContext.prototype)) {
hdrFolder.name = 'HDR settings';
return;
}
const configuration = context.getConfiguration();
const toneMappingModeMatches =
configuration.toneMapping.mode === simulationParams.toneMappingMode;
hdrFolder.name = `HDR settings ${
hdrMediaQuery.matches ? '' : '⚠️ Your display is not compatible'
toneMappingModeMatches ? '' : '⚠️ Your browser doesn\'t support HDR canvas'

Check failure on line 363 in sample/particles/main.ts

View workflow job for this annotation

GitHub Actions / build

Replace `'⚠️·Your·browser·doesn\'t·support·HDR·canvas'` with `"⚠️·Your·browser·doesn't·support·HDR·canvas"`
}`;
}
updateHdrFolderName();
hdrMediaQuery.onchange = updateHdrFolderName;

const computePipeline = device.createComputePipeline({
Expand Down

0 comments on commit a5be0dc

Please sign in to comment.