Skip to content

Commit

Permalink
Merge branch 'TurboWarp:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
LilyMakesThings authored Oct 10, 2024
2 parents 9d343f3 + 366bfbb commit b4a111e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/ShaderManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,22 @@ class ShaderManager {
const vsFullText = definesText + this.exports.sprite.vert;
const fsFullText = definesText + this.exports.sprite.frag;

return twgl.createProgramInfo(this._gl, [vsFullText, fsFullText]);
let errorMessage = null;
const onError = newError => {
// twgl won't log the error when we provide a custom error callback, so log it ourselves
console.error(newError);

// For the error that we throw, just include the actual error from WebGL, not all the fancy
// extras that twgl adds to the error messages.
const match = newError.match(/\*\*\* Error compiling shader: ([\s\S]+)/);
errorMessage = match ? match[1].trim() : newError;
};

const program = twgl.createProgramInfo(this._gl, [vsFullText, fsFullText], null, null, onError);
if (!program) {
throw new Error(`Failed to compile shader (mode ${drawMode}, effects ${effectBits}): ${errorMessage}`);
}
return program;
}
}

Expand Down

0 comments on commit b4a111e

Please sign in to comment.