From c6f8bc4b5abfd7a72afd1eee44afe134b55c3aa1 Mon Sep 17 00:00:00 2001 From: "A.Olokhtonov" Date: Sat, 25 May 2024 01:13:27 +0300 Subject: [PATCH] Fix first stroke preview not showing --- client/speed.js | 9 +++++---- client/webgl_draw.js | 8 ++++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/client/speed.js b/client/speed.js index 0db8319..70c5098 100644 --- a/client/speed.js +++ b/client/speed.js @@ -65,27 +65,28 @@ async function init_wasm(state) { state.wasm.buffers = { 'xs': { - 'offset': state.wasm.exports.alloc_static(initial), 'used': 0, 'cap': initial }, 'ys': { - 'offset': state.wasm.exports.alloc_static(initial), 'used': 0, 'cap': initial }, 'coords_from': { - 'offset': state.wasm.exports.alloc_static(initial), 'used': 0, 'cap': initial }, 'pressures': { - 'offset': state.wasm.exports.alloc_static(initial), 'used': 0, 'cap': initial }, }; + state.wasm.buffers['xs'].offset = state.wasm.exports.alloc_static(initial); + state.wasm.buffers['ys'].offset = state.wasm.exports.alloc_static(initial); + state.wasm.buffers['pressures'].offset = state.wasm.exports.alloc_static(initial); + state.wasm.buffers['coords_from'].offset = state.wasm.exports.alloc_static(initial); + const mem = state.wasm.memory.buffer; state.wasm.buffers['xs'].tv = tv_create_on(Float32Array, initial / 4, diff --git a/client/webgl_draw.js b/client/webgl_draw.js index 75ffea7..f3610cd 100644 --- a/client/webgl_draw.js +++ b/client/webgl_draw.js @@ -323,6 +323,14 @@ async function draw(state, context, animate, ts) { gl.bindTexture(gl.TEXTURE_2D, context.textures['dynamic_stroke_data']); upload_square_rgba16ui_texture(gl, context.dynamic_stroke_data, config.dynamic_stroke_texture_size); + gl.uniform2f(locations['u_res'], context.canvas.width, context.canvas.height); + gl.uniform2f(locations['u_scale'], state.canvas.zoom, state.canvas.zoom); + gl.uniform2f(locations['u_translation'], state.canvas.offset.x, state.canvas.offset.y); + gl.uniform1i(locations['u_stroke_count'], context.dynamic_stroke_count); + gl.uniform1i(locations['u_debug_mode'], state.debug.red); + gl.uniform1i(locations['u_stroke_data'], 0); + gl.uniform1i(locations['u_stroke_texture_size'], config.dynamic_stroke_texture_size); + gl.enableVertexAttribArray(locations['a_a']); gl.enableVertexAttribArray(locations['a_b']); gl.enableVertexAttribArray(locations['a_stroke_id']);