@ -4,9 +4,9 @@ let textures = {};
@@ -4,9 +4,9 @@ let textures = {};
let timers = { } ;
let config = {
bytes _per _quad : 28 ,
w : 32 ,
h : 3 2,
padding : 2 ,
w : 40 ,
h : 20 ,
padding : 1 ,
predefined _colors : {
'Np' : [ 75 , 62 , 143 ] ,
@ -192,7 +192,7 @@ function draw(ts, animation) {
@@ -192,7 +192,7 @@ function draw(ts, animation) {
}
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 . 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' ] ) ;
@ -200,16 +200,17 @@ function draw(ts, animation) {
@@ -200,16 +200,17 @@ function draw(ts, animation) {
gl . uniform1f ( program . locations [ 'u_fade' ] , fade ) ;
gl . uniform1i ( program . locations [ 'u_solid' ] , 1 ) ;
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_size' ] ) ;
gl . enableVertexAttribArray ( program . locations [ 'a_color' ] ) ;
gl . enableVertexAttribArray ( program . locations [ 'a_uv' ] ) ;
gl . vertexAttribPointer ( program . locations [ 'a_pos' ] , 2 , gl . FLOAT , false , 2 * 4 , 0 ) ;
gl . vertexAttribPointer ( program . locations [ 'a_pos' ] , 2 , gl . FLOAT , false , 2 * 4 , 0 ) ;
gl . vertexAttribPointer ( program . locations [ 'a_size' ] , 2 , gl . FLOAT , false , 2 * 4 , clipped . pos . byteLength ) ;
gl . vertexAttribPointer ( program . locations [ 'a_color' ] , 4 , gl . UNSIGNED _BYTE , true , 4 * 1 , clipped . pos . byteLength + clipped . size . byteLength ) ;
gl . vertexAttribPointer ( program . locations [ 'a_uv' ] , 2 , gl . FLOAT , false , 2 * 4 , clipped . pos . byteLength + clipped . size . byteLength + clipped . color . byteLength ) ;
gl . vertexAttribPointer ( program . locations [ 'a_color' ] , 4 , gl . UNSIGNED _BYTE , true , 4 * 1 , clipped . pos . byteLength + clipped . size . byteLength ) ;
gl . vertexAttribPointer ( program . locations [ 'a_uv' ] , 2 , gl . FLOAT , false , 2 * 4 , clipped . pos . byteLength + clipped . size . byteLength + clipped . color . byteLength ) ;
gl . vertexAttribDivisor ( program . locations [ 'a_pos' ] , 1 ) ;
gl . vertexAttribDivisor ( program . locations [ 'a_size' ] , 1 ) ;
@ -219,9 +220,19 @@ function draw(ts, animation) {
@@ -219,9 +220,19 @@ function draw(ts, animation) {
gl . drawArraysInstanced ( gl . TRIANGLES , 0 , 6 , clipped . count ) ;
if ( fade > 0 ) {
// Stage names
gl . bindTexture ( gl . TEXTURE _2D , textures [ 'raster' ] ) ;
gl . uniform1i ( program . locations [ 'u_solid' ] , 0 ) ;
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 ) ;
}
@ -324,6 +335,7 @@ function init_webgl() {
@@ -324,6 +335,7 @@ function init_webgl() {
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 . bindTexture ( gl . TEXTURE _2D , textures [ 'numbers' ] ) ;
gl . texParameteri ( gl . TEXTURE _2D , gl . TEXTURE _MIN _FILTER , gl . LINEAR ) ;
gl . texParameteri ( gl . TEXTURE _2D , gl . TEXTURE _MAG _FILTER , gl . NEAREST ) ;