@ -273,6 +273,7 @@ async function draw(state, context, animate, ts) {
@@ -273,6 +273,7 @@ async function draw(state, context, animate, ts) {
gl . uniform1i ( locations [ 'u_debug_mode' ] , state . debug . red ) ;
gl . uniform1i ( locations [ 'u_stroke_data' ] , 0 ) ;
gl . uniform1i ( locations [ 'u_stroke_texture_size' ] , config . stroke _texture _size ) ;
gl . uniform1f ( locations [ 'u_fixed_pixel_width' ] , 0 ) ;
gl . enableVertexAttribArray ( locations [ 'a_a' ] ) ;
gl . enableVertexAttribArray ( locations [ 'a_b' ] ) ;
@ -328,10 +329,12 @@ async function draw(state, context, animate, ts) {
@@ -328,10 +329,12 @@ async function draw(state, context, animate, ts) {
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 . uniform1f ( locations [ 'u_fixed_pixel_width' ] , 0 ) ;
gl . enableVertexAttribArray ( locations [ 'a_a' ] ) ;
gl . enableVertexAttribArray ( locations [ 'a_b' ] ) ;
@ -357,6 +360,55 @@ async function draw(state, context, animate, ts) {
@@ -357,6 +360,55 @@ async function draw(state, context, animate, ts) {
gl . vertexAttribDivisor ( locations [ 'a_pressure' ] , 0 ) ;
}
// HUD: resize handles, etc
if ( context . active _image !== null ) {
const handles = geometry _generate _handles ( state , context , context . active _image ) ;
const ui _segments = 7 * 4 - 1 ; // each square = 4, each line = 1, square->line = 1, line->square = 1
gl . bindBuffer ( gl . ARRAY _BUFFER , buffers [ 'b_instance' ] ) ;
gl . bufferData ( gl . ARRAY _BUFFER , handles . points . byteLength + handles . ids . byteLength + handles . pressures . byteLength , gl . STREAM _DRAW ) ;
gl . bufferSubData ( gl . ARRAY _BUFFER , 0 , handles . points ) ;
gl . bufferSubData ( gl . ARRAY _BUFFER , handles . points . byteLength , handles . ids ) ;
gl . bufferSubData ( gl . ARRAY _BUFFER , handles . points . byteLength + handles . ids . byteLength , handles . pressures ) ;
gl . bindTexture ( gl . TEXTURE _2D , context . textures [ 'ui' ] ) ;
upload _square _rgba16ui _texture ( gl , handles . stroke _data , config . ui _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' ] , 8 ) ;
gl . uniform1i ( locations [ 'u_debug_mode' ] , 0 ) ;
gl . uniform1i ( locations [ 'u_stroke_data' ] , 0 ) ;
gl . uniform1i ( locations [ 'u_stroke_texture_size' ] , config . ui _texture _size ) ;
gl . uniform1f ( locations [ 'u_fixed_pixel_width' ] , 2 ) ;
gl . enableVertexAttribArray ( locations [ 'a_a' ] ) ;
gl . enableVertexAttribArray ( locations [ 'a_b' ] ) ;
gl . enableVertexAttribArray ( locations [ 'a_stroke_id' ] ) ;
gl . enableVertexAttribArray ( locations [ 'a_pressure' ] ) ;
gl . vertexAttribPointer ( locations [ 'a_a' ] , 2 , gl . FLOAT , false , 2 * 4 , 0 ) ;
gl . vertexAttribPointer ( locations [ 'a_b' ] , 2 , gl . FLOAT , false , 2 * 4 , 2 * 4 ) ;
gl . vertexAttribIPointer ( locations [ 'a_stroke_id' ] , 1 , gl . INT , 4 , handles . points . byteLength ) ;
gl . vertexAttribPointer ( locations [ 'a_pressure' ] , 2 , gl . UNSIGNED _BYTE , true , 1 , handles . points . byteLength + handles . ids . byteLength ) ;
gl . vertexAttribDivisor ( locations [ 'a_a' ] , 1 ) ;
gl . vertexAttribDivisor ( locations [ 'a_b' ] , 1 ) ;
gl . vertexAttribDivisor ( locations [ 'a_stroke_id' ] , 1 ) ;
gl . vertexAttribDivisor ( locations [ 'a_pressure' ] , 1 ) ;
// Static draw (everything already bound)
gl . drawArraysInstanced ( gl . TRIANGLES , 0 , 6 , ui _segments ) ;
// I don't really know why I need to do this, but it
// makes background patter drawcall work properly
gl . vertexAttribDivisor ( locations [ 'a_a' ] , 0 ) ;
gl . vertexAttribDivisor ( locations [ 'a_b' ] , 0 ) ;
gl . vertexAttribDivisor ( locations [ 'a_stroke_id' ] , 0 ) ;
gl . vertexAttribDivisor ( locations [ 'a_pressure' ] , 0 ) ;
}
document . getElementById ( 'debug-stats' ) . innerHTML = `
< span > Strokes onscreen : $ { context . clipped _indices . size } < / s p a n >
< span > Segments onscreen : $ { segment _count } < / s p a n >