Skip to content

Commit 97d0733

Browse files
committed
added gl-resize event
1 parent adb35ee commit 97d0733

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Called at the start of the WebGL frame.
9999
### `gl-error(reason)`
100100
Called if there was an error initializing webgl
101101

102-
### `resize(width, height)`
102+
### `gl-resize(width, height)`
103103
Called when the WebGL window is resized
104104

105105

index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,14 @@ function createGLShell(options) {
8585
shell.emit("gl-init")
8686
})
8787

88-
89-
9088
function resize() {
91-
shell.canvas.width = (shell._width / scale)|0
92-
shell.canvas.height = (shell._height / scale)|0
89+
var nw = (shell._width/scale)|0
90+
var nh = (shell._height/scale)|0
91+
shell.canvas.width = nw
92+
shell.canvas.height = nh
9393
shell.canvas.style.width = shell._width + 'px'
9494
shell.canvas.style.height = shell._height + 'px'
95+
shell.emit("gl-resize", nw, nh)
9596
}
9697

9798
Object.defineProperty(shell, 'scale', {

0 commit comments

Comments
 (0)