Skip to content

Commit

Permalink
feat(webgl): update glCanvas() return type
Browse files Browse the repository at this point in the history
- add `resize` handler to result which can later be called to
  resize the canvas (with DPR) and update the GL viewport
  • Loading branch information
postspectacular committed Apr 18, 2023
1 parent 00470d1 commit 4af5e04
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/webgl/src/canvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ export const glCanvas = (opts: Partial<WeblGLCanvasOpts> = {}) => {
canvas,
gl,
ext: getExtensions(gl, opts.ext!),
resize: (width: number, height: number) => {
adaptDPI(
canvas,
width,
height,
opts.autoScale !== false ? window.devicePixelRatio : 1
);
gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
},
};
};

Expand Down

0 comments on commit 4af5e04

Please sign in to comment.