From bf7e5e806ce6a131977741b4b97eb3cd1d370316 Mon Sep 17 00:00:00 2001 From: Reinder Nijhoff Date: Thu, 9 Nov 2023 15:27:16 +0100 Subject: [PATCH] Added a main property, so you can always get the 'main renderer' from a buffer --- src/lib/Renderer.ts | 2 ++ src/lib/RendererInstance.ts | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/lib/Renderer.ts b/src/lib/Renderer.ts index 13d9e58..1182bb9 100644 --- a/src/lib/Renderer.ts +++ b/src/lib/Renderer.ts @@ -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 @@ -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; diff --git a/src/lib/RendererInstance.ts b/src/lib/RendererInstance.ts index dd722bc..0ed1adb 100644 --- a/src/lib/RendererInstance.ts +++ b/src/lib/RendererInstance.ts @@ -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'); @@ -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; }