Skip to content

Commit 61d009f

Browse files
committed
Fix bug with graphical mode
1 parent 3b3d08f commit 61d009f

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

src/backend/mode_gpu.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,14 @@
116116
GPU.prototype._mode_gpu = function(kernel, opt) {
117117
var gpu = this;
118118

119-
var canvas = gpu._canvas;
120-
if (!gpu._canvas) {
121-
canvas = gpu._canvas = GPUUtils.init_canvas();
119+
var canvas = this._canvas;
120+
if (!canvas) {
121+
canvas = this._canvas = GPUUtils.init_canvas();
122122
}
123123

124-
var gl = gpu._webgl;
125-
if (!gpu._webgl) {
126-
gl = gpu._webgl = GPUUtils.init_webgl(canvas);
124+
var gl = this._webgl;
125+
if (!gl) {
126+
gl = this._webgl = GPUUtils.init_webgl(canvas);
127127
}
128128

129129
var builder = this.functionBuilder;
@@ -573,6 +573,13 @@
573573
} else {
574574
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, texSize[0], texSize[1], 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
575575
}
576+
577+
if (opt.graphical) {
578+
gl.bindRenderbuffer(gl.RENDERBUFFER, null);
579+
gl.bindFramebuffer(gl.FRAMEBUFFER, null);
580+
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
581+
return;
582+
}
576583

577584
var framebuffer = gl.createFramebuffer();
578585
framebuffer.width = texSize[0];
@@ -585,10 +592,6 @@
585592
if (opt.outputToTexture) {
586593
return new GPUTexture(gpu, outputTexture, texSize, opt.dimensions);
587594
} else {
588-
if (opt.graphical) {
589-
return;
590-
}
591-
592595
var result;
593596
if (opt.floatOutput) {
594597
result = new Float32Array(texSize[0]*texSize[1]*4);

0 commit comments

Comments
 (0)