Skip to content

Commit

Permalink
feat(webgl): add opt unbind flag for .configure()
Browse files Browse the repository at this point in the history
- default remains true to keep existing behavior, but provide
  escape hatch where needed/useful (i.e. multipass stuff)
- update impls for FBO, RBO, Texture
  • Loading branch information
postspectacular committed Aug 12, 2020
1 parent cfce142 commit 0e5cc2b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/webgl/src/fbo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class FBO implements IFbo {
return true;
}

configure(opts: Partial<FboOpts>) {
configure(opts: Partial<FboOpts>, unbind = true) {
const gl = this.gl;
this.bind();
if (opts.tex) {
Expand Down Expand Up @@ -109,7 +109,7 @@ export class FBO implements IFbo {
);
}
this.validate();
return this.unbind();
return unbind ? this.unbind() : true;
}

validate() {
Expand Down
5 changes: 2 additions & 3 deletions packages/webgl/src/rbo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class RBO implements IRenderBuffer {
return true;
}

configure(opts: RboOpts) {
configure(opts: RboOpts, unbind = true) {
const gl = this.gl;
this.bind();
this.format = opts.format || gl.DEPTH_COMPONENT16;
Expand All @@ -42,8 +42,7 @@ export class RBO implements IRenderBuffer {
opts.width,
opts.height
);
this.unbind();
return true;
return unbind ? this.unbind() : true;
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/webgl/src/texture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class Texture implements ITexture {
this.configure(opts);
}

configure(opts: Partial<TextureOpts> = {}) {
configure(opts: Partial<TextureOpts> = {}, unbind = true) {
const gl = this.gl;
const isGL2 = isGL2Context(gl);
const target = opts.target || this.target || TextureTarget.TEXTURE_2D;
Expand Down Expand Up @@ -219,7 +219,7 @@ export class Texture implements ITexture {
);
}

gl.bindTexture(this.target, null);
unbind && gl.bindTexture(this.target, null);

return true;
}
Expand Down

0 comments on commit 0e5cc2b

Please sign in to comment.