diff --git a/client/client_send.js b/client/client_send.js index 922cb09..6de9600 100644 --- a/client/client_send.js +++ b/client/client_send.js @@ -41,6 +41,7 @@ function ser_u32(s, value) { } function ser_align(s, to) { + // TODO: non-stupid version of this while (s.offset % to != 0) { s.offset++; } diff --git a/client/index.html b/client/index.html index 1a9f710..cdf999d 100644 --- a/client/index.html +++ b/client/index.html @@ -7,20 +7,20 @@ - + - - - - - - - - + + + + + + + + - - - + + +
diff --git a/client/webgl_draw.js b/client/webgl_draw.js index 2555824..bb998b6 100644 --- a/client/webgl_draw.js +++ b/client/webgl_draw.js @@ -42,12 +42,12 @@ function draw(state, context) { const npoints = context.point_serializer.offset / (4 * 2); const nstrokes = context.quad_serializer.offset / (6 * 4 * 4); - ser_align(context.point_serializer, 8192); - if (npoints > 0) { // TOOD: if points changed if (true) { - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RG32F, Math.min(npoints, 8192), Math.max(1, Math.ceil(npoints / 8192)), 0, gl.RG, gl.FLOAT, new Float32Array(context.point_serializer.buffer, 0, context.point_serializer.offset / 4)); + const texture_width = Math.min(npoints, 8192); + const texture_height = Math.max(1, Math.ceil(npoints / 8192)); + gl.texImage2D(gl.TEXTURE_2D, 0, gl.RG32F, texture_width, texture_height, 0, gl.RG, gl.FLOAT, new Float32Array(context.point_serializer.buffer, 0, context.point_serializer.size / 4)); } gl.activeTexture(gl.TEXTURE0 + 1); diff --git a/client/webgl_geometry.js b/client/webgl_geometry.js index 128d86a..ade6a76 100644 --- a/client/webgl_geometry.js +++ b/client/webgl_geometry.js @@ -39,7 +39,7 @@ function push_stroke(context, stroke) { // if (stroke.stroke_id !== 1123776468) { // return; // } - + const stroke_width = stroke.width; const points = stroke.points; const color_u32 = stroke.color; @@ -132,14 +132,17 @@ function geometry_prepare_stroke(state) { function geometry_add_stroke(state, context, stroke) { if (!state.online || !stroke) return; - if (stroke.points.length < 2) return; const stroke_quads = count_stroke_quads(stroke.points); // const stroke_quads = Math.ceil(stroke.points.length / MAX_POINTS_PER_QUAD); // Points - const point_bytes_left = context.point_serializer.size - context.point_serializer.offset; - const point_bytes_needed = stroke.points.length * config.bytes_per_point; + let point_bytes_left = context.point_serializer.size - context.point_serializer.offset; + let point_bytes_needed = stroke.points.length * config.bytes_per_point; + + if (point_bytes_needed % 8192 != 0) { + point_bytes_needed += 8192 - point_bytes_needed % 8192; + } if (point_bytes_left < point_bytes_needed) { const extend_points_by = Math.ceil((context.point_serializer.size + point_bytes_needed) * 1.62);