| 4 | export const DEFAULT_HEIGHT = 1080; |
| 5 | |
| 6 | export function createContext( |
| 7 | canvas: HTMLCanvasElement, |
| 8 | width: number = DEFAULT_WIDTH, |
| 9 | height: number = DEFAULT_HEIGHT, |
| 10 | ): WebGLRenderingContext | null { |
| 11 | const gl = canvas.getContext("webgl", { preserveDrawingBuffer: true }); |
| 12 | if (!gl) return null; |
| 13 | gl.viewport(0, 0, width, height); |
| 14 | gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false); |
| 15 | return gl as WebGLRenderingContext; |
| 16 | } |
| 17 | |
| 18 | export function setupQuad(gl: WebGLRenderingContext): WebGLBuffer { |
| 19 | const buf = gl.createBuffer(); |