17 lines
368 B
TypeScript
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;
|
|
};
|