diff --git a/src/content_script/fcn_bindings.js b/src/content_script/fcn_bindings.js index af00174..5be6f75 100644 --- a/src/content_script/fcn_bindings.js +++ b/src/content_script/fcn_bindings.js @@ -189,6 +189,7 @@ var glpFcnBindings = { }, bindFramebuffer: function(original, args, name) { this.glp().bufferViewer.bindFramebuffer(args[1]); + this.glp().pixelInspector.bindFrameBuffer(args[1]) return original.apply(this, args); }, unbindFramebuffer: function(original, args, name) { @@ -209,6 +210,7 @@ var glpFcnBindings = { }, bindRenderbuffer: function(original, args, name) { this.glp().bufferViewer.bindRenderbuffer(args[1]); + this.glp().pixelInspector.bindRenderBuffer(args[1]) return original.apply(this, args); }, unbindRenderbuffer: function(original, args, name) { diff --git a/src/content_script/pixel_inspector.js b/src/content_script/pixel_inspector.js index 3059a90..1f298b8 100644 --- a/src/content_script/pixel_inspector.js +++ b/src/content_script/pixel_inspector.js @@ -14,6 +14,8 @@ var glpPixelInspector = function (gl) { this.originalPrograms = {}; this.locationMap = {}; this.enabled = false; + this.framebufferIsBound = false; + this.renderbufferIsBound = false; } /** @@ -94,6 +96,9 @@ glpPixelInspector.prototype.applyUniform = function (uniform) { * @return {WebGLShader} Pixel Inspector Shader */ glpPixelInspector.prototype.enable = function() { + if (this.framebufferIsBound || this.renderbufferIsBound) { + return; + } this.blendProp = this.gl.getParameter(this.gl.BLEND); this.gl.enable(this.gl.BLEND); @@ -146,6 +151,28 @@ glpPixelInspector.prototype.disable = function() { } } +glpPixelInspector.prototype.bindFrameBuffer = function(enable) { + this.framebufferIsBound = !!enable; + this.toggleByBuffer(!!enable); +} + +glpPixelInspector.prototype.bindRenderBuffer = function(enable) { + this.renderbufferIsBound = !!enable; + this.toggleByBuffer(!!enable); +} + +glpPixelInspector.prototype.toggleByBuffer = function(enable) { + if (!this.enabled) { + return; + } + + if (!this.framebufferIsBound && !this.renderbufferIsBound) { + this.enable(); + } else { + this.disable(); + } +} + /** * Copies uniforms from oldProgram to newProgram */