Skip to content

Commit

Permalink
Added a main property, so you can always get the 'main renderer' from…
Browse files Browse the repository at this point in the history
… a buffer
  • Loading branch information
reindernijhoff committed Nov 9, 2023
1 parent 2f73173 commit bf7e5e8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib/Renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {UniformType} from "./Uniform.js";
import type Program from "./Program.js";
import type {RendererBuffer} from "./RendererBuffer.js";
import type {Texture} from "./Texture.js.js";
import type {RendererInstance} from "./RendererInstance.js";

/**
* @typedef {Object} ImageOptions
Expand All @@ -25,6 +26,7 @@ export class Renderer {
public width: number = 0;
public height: number = 0;
public program!: Program;
public main!: RendererInstance;

gl: WebGLInstance;
protected frame: number = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/lib/RendererInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class RendererInstance extends Renderer {
this.options = {...ImageEffectRenderer.defaultOptions, ...options};
this.index = RendererInstance.index++;
this.container = container;
this.main = this;

if (this.options.useSharedContext) {
this.canvas = document.createElement('canvas');
Expand Down Expand Up @@ -89,6 +90,7 @@ export class RendererInstance extends Renderer {
}
const newBuffer = new RendererBuffer(this.gl, options);
newBuffer.program = this.gl.compileShader(shader);
newBuffer.main = this;
return this.buffers[i] = newBuffer;
}

Expand Down

0 comments on commit bf7e5e8

Please sign in to comment.