diff --git a/client/index.html b/client/index.html index d2db833..b9eb262 100644 --- a/client/index.html +++ b/client/index.html @@ -7,20 +7,20 @@ - + - - - - - - - - + + + + + + + + - - - + + +
diff --git a/client/index.js b/client/index.js index fa1207a..b78d821 100644 --- a/client/index.js +++ b/client/index.js @@ -1,9 +1,9 @@ document.addEventListener('DOMContentLoaded', main); const config = { - ws_url: 'wss://desk.local/ws/', - ping_url: 'https://desk.local/api/ping', - image_url: 'https://desk.local/images/', + ws_url: 'wss://192.168.100.2/ws/', + ping_url: 'https://192.168.100.2/api/ping', + image_url: 'https://192.168.100.2/images/', sync_timeout: 1000, ws_reconnect_timeout: 2000, brush_preview_timeout: 1000, @@ -114,6 +114,8 @@ function main() { 'frametime_window': [], 'frametime_window_head': 0, + 'static_upload_from': 0, + 'need_static_allocate': true, 'need_static_upload': true, 'need_dynamic_upload': false, diff --git a/client/webgl_draw.js b/client/webgl_draw.js index 135ff21..6dd2518 100644 --- a/client/webgl_draw.js +++ b/client/webgl_draw.js @@ -47,9 +47,21 @@ function draw(state, context) { gl.vertexAttribPointer(locations['a_line'], 4, gl.FLOAT, false, config.bytes_per_point, 4 * 3); gl.vertexAttribPointer(locations['a_color'], 3, gl.UNSIGNED_BYTE, true, config.bytes_per_point, 4 * 3 + 4 * 4); + if (context.need_static_allocate) { + console.debug('static allocate'); + gl.bufferData(gl.ARRAY_BUFFER, context.static_serializer.size, gl.DYNAMIC_DRAW); + context.need_static_allocate = false; + context.static_upload_from = 0; + context.need_static_upload = true; + } + if (context.need_static_upload) { - gl.bufferData(gl.ARRAY_BUFFER, new Uint8Array(context.static_serializer.buffer, 0, context.static_serializer.offset), gl.STATIC_DRAW); + console.debug('static upload'); + const upload_offset = context.static_upload_from; + const upload_size = context.static_serializer.offset - upload_offset; + gl.bufferSubData(gl.ARRAY_BUFFER, upload_offset, new Uint8Array(context.static_serializer.buffer, upload_offset, upload_size)); context.need_static_upload = false; + context.static_upload_from = context.static_serializer.offset; } gl.drawArrays(gl.TRIANGLES, 0, static_points); diff --git a/client/webgl_geometry.js b/client/webgl_geometry.js index 48f0e13..134723f 100644 --- a/client/webgl_geometry.js +++ b/client/webgl_geometry.js @@ -84,6 +84,10 @@ function geometry_prepare_stroke(state) { return null; } + if (state.players[state.me].points.length === 0) { + return null; + } + return { 'color': state.players[state.me].color, 'width': state.players[state.me].width, @@ -101,10 +105,10 @@ function geometry_add_stroke(state, context, stroke) { if (bytes_left < bytes_needed) { const extend_to = Math.ceil((context.static_serializer.size + bytes_needed) * 1.62); context.static_serializer = ser_extend(context.static_serializer, extend_to); + context.need_static_allocate = true; } push_stroke(context.static_serializer, stroke); - context.need_static_upload = true; }