Cesium-Examples/examples/webgpuEx/1.1、默认设置.html
2025-03-11 17:51:04 +08:00

37 lines
1.2 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!--********************************************************************
* by jiawanlong
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<style>
* {
margin: 0;
padding: 0;
overflow: hidden;
}
</style>
</head>
<body>
<canvas id="webgpu" width="500" height="500"></canvas>
<script type="module">
// 1. 初始化WebGPU
const adapter = await navigator.gpu.requestAdapter();
// 获取GPU设备对象通过GPU设备对象device的WebGPU API可以控制GPU渲染过程
const device = await adapter.requestDevice();
//配置WebGPU上下文把id名为webgpu的Canvas元素作为WebGPU的画布
const canvas = document.getElementById('webgpu');
const context = canvas.getContext('webgpu');
const format = navigator.gpu.getPreferredCanvasFormat();//获取浏览器默认的
context.configure({
device: device,//WebGPU渲染器使用的GPU设备对象
format: format,//WebGPU渲染器使用的颜色格式
});
</script>
</body>
</html>