|
@@ -5,17 +5,21 @@ import { NoToneMapping, AddOperation, MixOperation, MultiplyOperation, CubeRefra
|
|
|
|
|
|
let programIdCount = 0;
|
|
|
|
|
|
-function addLineNumbers( string ) {
|
|
|
+function handleSource( string, errorLine ) {
|
|
|
|
|
|
const lines = string.split( '\n' );
|
|
|
+ const lines2 = [];
|
|
|
|
|
|
- for ( let i = 0; i < lines.length; i ++ ) {
|
|
|
+ const from = Math.max( errorLine - 6, 0 );
|
|
|
+ const to = Math.min( errorLine + 6, lines.length );
|
|
|
|
|
|
- lines[ i ] = ( i + 1 ) + ': ' + lines[ i ];
|
|
|
+ for ( let i = from; i < to; i ++ ) {
|
|
|
+
|
|
|
+ lines2.push( ( i + 1 ) + ': ' + lines[ i ] );
|
|
|
|
|
|
}
|
|
|
|
|
|
- return lines.join( '\n' );
|
|
|
+ return lines2.join( '\n' );
|
|
|
|
|
|
}
|
|
|
|
|
@@ -42,10 +46,12 @@ function getShaderErrors( gl, shader, type ) {
|
|
|
|
|
|
if ( status && errors === '' ) return '';
|
|
|
|
|
|
+ const errorLine = parseInt( /ERROR: 0:(\d+)/.exec( errors )[ 1 ] );
|
|
|
+
|
|
|
// --enable-privileged-webgl-extension
|
|
|
// console.log( '**' + type + '**', gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( shader ) );
|
|
|
|
|
|
- return type.toUpperCase() + '\n\n' + errors + '\n\n' + addLineNumbers( gl.getShaderSource( shader ) );
|
|
|
+ return type.toUpperCase() + '\n\n' + errors + '\n\n' + handleSource( gl.getShaderSource( shader ), errorLine );
|
|
|
|
|
|
}
|
|
|
|