|
|
@ -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_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); |
|
|
|
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) { |
|
|
|
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.need_static_upload = false; |
|
|
|
|
|
|
|
context.static_upload_from = context.static_serializer.offset; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
gl.drawArrays(gl.TRIANGLES, 0, static_points); |
|
|
|
gl.drawArrays(gl.TRIANGLES, 0, static_points); |
|
|
|