@ -4,9 +4,9 @@ let textures = {};
let timers = { } ;
let timers = { } ;
let config = {
let config = {
bytes _per _quad : 28 ,
bytes _per _quad : 28 ,
w : 32 ,
w : 40 ,
h : 3 2,
h : 20 ,
padding : 2 ,
padding : 1 ,
predefined _colors : {
predefined _colors : {
'Np' : [ 75 , 62 , 143 ] ,
'Np' : [ 75 , 62 , 143 ] ,
@ -192,7 +192,7 @@ function draw(ts, animation) {
}
}
gl . uniform2f ( program . locations [ 'u_res' ] , canvas . width , canvas . height ) ;
gl . uniform2f ( program . locations [ 'u_res' ] , canvas . width , canvas . height ) ;
gl . uniform2f ( program . locations [ 'u_translation' ] , offset . x , offset . y ) ;
gl . uniform2f ( program . locations [ 'u_translation' ] , Math . round ( offset . x ) , Math . round ( offset . y ) ) ;
gl . uniform1f ( program . locations [ 'u_scale' ] , zoom ) ;
gl . uniform1f ( program . locations [ 'u_scale' ] , zoom ) ;
gl . uniform2f ( program . locations [ 'u_textile' ] , config . w / config . raster _texture _size , config . h / config . raster _texture _size ) ;
gl . uniform2f ( program . locations [ 'u_textile' ] , config . w / config . raster _texture _size , config . h / config . raster _texture _size ) ;
gl . uniform1i ( program . locations [ 'u_texture' ] , textures [ 'raster' ] ) ;
gl . uniform1i ( program . locations [ 'u_texture' ] , textures [ 'raster' ] ) ;
@ -200,6 +200,7 @@ function draw(ts, animation) {
gl . uniform1f ( program . locations [ 'u_fade' ] , fade ) ;
gl . uniform1f ( program . locations [ 'u_fade' ] , fade ) ;
gl . uniform1i ( program . locations [ 'u_solid' ] , 1 ) ;
gl . uniform1i ( program . locations [ 'u_solid' ] , 1 ) ;
gl . uniform1i ( program . locations [ 'u_single' ] , 0 ) ;
gl . uniform1i ( program . locations [ 'u_single' ] , 0 ) ;
gl . uniform1i ( program . locations [ 'u_extra' ] , 0 ) ;
gl . enableVertexAttribArray ( program . locations [ 'a_pos' ] ) ;
gl . enableVertexAttribArray ( program . locations [ 'a_pos' ] ) ;
gl . enableVertexAttribArray ( program . locations [ 'a_size' ] ) ;
gl . enableVertexAttribArray ( program . locations [ 'a_size' ] ) ;
@ -219,9 +220,19 @@ function draw(ts, animation) {
gl . drawArraysInstanced ( gl . TRIANGLES , 0 , 6 , clipped . count ) ;
gl . drawArraysInstanced ( gl . TRIANGLES , 0 , 6 , clipped . count ) ;
if ( fade > 0 ) {
if ( fade > 0 ) {
// Stage names
gl . bindTexture ( gl . TEXTURE _2D , textures [ 'raster' ] ) ;
gl . bindTexture ( gl . TEXTURE _2D , textures [ 'raster' ] ) ;
gl . uniform1i ( program . locations [ 'u_solid' ] , 0 ) ;
gl . uniform1i ( program . locations [ 'u_solid' ] , 0 ) ;
gl . uniform1i ( program . locations [ 'u_single' ] , 1 ) ;
gl . uniform1i ( program . locations [ 'u_single' ] , 1 ) ;
gl . uniform1i ( program . locations [ 'u_extra' ] , 0 ) ;
gl . drawArraysInstanced ( gl . TRIANGLES , 0 , 6 , clipped . count ) ;
// Cycle counts
gl . bindTexture ( gl . TEXTURE _2D , textures [ 'raster' ] ) ;
gl . uniform1i ( program . locations [ 'u_solid' ] , 0 ) ;
gl . uniform1i ( program . locations [ 'u_single' ] , 0 ) ;
gl . uniform1i ( program . locations [ 'u_extra' ] , 1 ) ;
// TODO: we need a set of alternative uvs here?
gl . drawArraysInstanced ( gl . TRIANGLES , 0 , 6 , clipped . count ) ;
gl . drawArraysInstanced ( gl . TRIANGLES , 0 , 6 , clipped . count ) ;
}
}
@ -324,6 +335,7 @@ function init_webgl() {
gl . texParameteri ( gl . TEXTURE _2D , gl . TEXTURE _MAG _FILTER , gl . NEAREST ) ;
gl . texParameteri ( gl . TEXTURE _2D , gl . TEXTURE _MAG _FILTER , gl . NEAREST ) ;
gl . texImage2D ( gl . TEXTURE _2D , 0 , gl . RGBA , config . raster _texture _size , config . raster _texture _size , 0 , gl . RGBA , gl . UNSIGNED _BYTE , zeroes ) ; // fill the whole texture once with zeroes to kill a warning about a partial upload
gl . texImage2D ( gl . TEXTURE _2D , 0 , gl . RGBA , config . raster _texture _size , config . raster _texture _size , 0 , gl . RGBA , gl . UNSIGNED _BYTE , zeroes ) ; // fill the whole texture once with zeroes to kill a warning about a partial upload
gl . bindTexture ( gl . TEXTURE _2D , textures [ 'numbers' ] ) ;
gl . bindTexture ( gl . TEXTURE _2D , textures [ 'numbers' ] ) ;
gl . texParameteri ( gl . TEXTURE _2D , gl . TEXTURE _MIN _FILTER , gl . LINEAR ) ;
gl . texParameteri ( gl . TEXTURE _2D , gl . TEXTURE _MIN _FILTER , gl . LINEAR ) ;
gl . texParameteri ( gl . TEXTURE _2D , gl . TEXTURE _MAG _FILTER , gl . NEAREST ) ;
gl . texParameteri ( gl . TEXTURE _2D , gl . TEXTURE _MAG _FILTER , gl . NEAREST ) ;