fleeting-garden/src/utils/graphics/initialize-context.ts
2023-05-21 11:01:31 +01:00

17 lines
368 B
TypeScript

export const initializeContext = ({
device,
canvas,
}: {
device: GPUDevice;
canvas: HTMLCanvasElement;
}): GPUCanvasContext => {
const context = canvas.getContext('webgpu') as any as GPUCanvasContext;
context.configure({
device: device,
format: navigator.gpu.getPreferredCanvasFormat(),
alphaMode: 'premultiplied',
});
return context;
};