]> zoso.dev Git - libnemo.git/commitdiff
Set clear color in static initializer.
authorChris Duncan <chris@zoso.dev>
Tue, 17 Dec 2024 22:36:19 +0000 (14:36 -0800)
committerChris Duncan <chris@zoso.dev>
Tue, 17 Dec 2024 22:36:19 +0000 (14:36 -0800)
src/lib/workers/pow.ts

index 17bbf2cfb65c08a8afac94131b6406dfced371e6..3a6e359fe4748f48b9ab48b2594dcc9fcbe8cded 100644 (file)
@@ -238,6 +238,7 @@ void main() {
        static {
                this.#gl = new OffscreenCanvas(this.#WORKLOAD, this.#WORKLOAD).getContext('webgl2')
                if (this.#gl == null) throw new Error('WebGL 2 is required')
+               this.#gl.clearColor(0, 0, 0, 1)
 
                this.#program = this.#gl.createProgram()
                if (this.#program == null) throw new Error('Failed to create shader program')
@@ -291,7 +292,6 @@ void main() {
                if (!/^[A-F-a-f0-9]{64}$/.test(hashHex)) throw new Error(`invalid_hash ${hashHex}`)
                if (typeof threshold !== 'number') throw new TypeError(`Invalid threshold ${threshold}`)
                if (this.#gl == null) throw new Error('WebGL 2 is required')
-               this.#gl.clearColor(0, 0, 0, 1)
 
                // Convert big-endian hash hex to buffer for use by shader
                const view = new DataView(new ArrayBuffer(32))