From 4a6d1d6640a310128a478d2b1f0bf590e06e4c36 Mon Sep 17 00:00:00 2001 From: "A.Olokhtonov" Date: Sat, 25 May 2024 01:40:37 +0300 Subject: [PATCH] Fix dummy offsets not getting inserted if first event is not a stroke --- client/client_recv.js | 2 +- client/index.html | 2 +- client/webgl_shaders.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/client_recv.js b/client/client_recv.js index 8f4e672..440f729 100644 --- a/client/client_recv.js +++ b/client/client_recv.js @@ -286,7 +286,7 @@ function handle_event(state, context, event, options = {}) { } } - const index_difference = state.events.length - (last_stroke === null ? 0 : last_stroke.index); + const index_difference = state.events.length - (last_stroke === null ? -1 : last_stroke.index); wasm_ensure_by(state, index_difference, event.coords.length); const pressures = state.wasm.buffers['pressures']; diff --git a/client/index.html b/client/index.html index 7a4b49c..e966fd0 100644 --- a/client/index.html +++ b/client/index.html @@ -9,7 +9,7 @@ - + diff --git a/client/webgl_shaders.js b/client/webgl_shaders.js index 69e17b6..0c78cd0 100644 --- a/client/webgl_shaders.js +++ b/client/webgl_shaders.js @@ -491,12 +491,12 @@ function init_webgl(state, context) { gl.bindTexture(gl.TEXTURE_2D, context.textures['stroke_data']); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA16UI, config.stroke_texture_size, config.stroke_texture_size, 0, gl.RGBA_INTEGER, gl.UNSIGNED_SHORT, null); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA16UI, config.stroke_texture_size, config.stroke_texture_size, 0, gl.RGBA_INTEGER, gl.UNSIGNED_SHORT, new Uint16Array(config.stroke_texture_size * config.stroke_texture_size * 4)); // fill the whole texture once with zeroes to kill a warning about a partial upload gl.bindTexture(gl.TEXTURE_2D, context.textures['dynamic_stroke_data']); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST); gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA16UI, config.dynamic_stroke_texture_size, config.dynamic_stroke_texture_size, 0, gl.RGBA_INTEGER, gl.UNSIGNED_SHORT, null); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA16UI, config.dynamic_stroke_texture_size, config.dynamic_stroke_texture_size, 0, gl.RGBA_INTEGER, gl.UNSIGNED_SHORT, new Uint16Array(config.dynamic_stroke_texture_size * config.dynamic_stroke_texture_size * 4)); // fill the whole texture once with zeroes to kill a warning about a partial upload const resize_canvas = (entries) => { // https://www.khronos.org/webgl/wiki/HandlingHighDPI