Skip to content

Commit

Permalink
fix: added missing error messages (#446)
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterlucas authored Nov 14, 2024
2 parents 3119232 + 1d08491 commit 9b7d807
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/core/renderers/webgl/WebGlCoreShader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,14 @@ export abstract class WebGlCoreShader extends CoreShader {
fragmentSource,
);
if (!vertexShader || !fragmentShader) {
throw new Error();
throw new Error(
`Unable to create shader type: ${glw.FRAGMENT_SHADER}. Source: ${fragmentSource}`,
);
}

const program = createProgram(glw, vertexShader, fragmentShader);
if (!program) {
throw new Error();
throw new Error('Unable to create program');
}
this.program = program;

Expand Down
9 changes: 5 additions & 4 deletions src/core/renderers/webgl/internal/ShaderUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,11 @@ export function createShader(
) {
const shader = glw.createShader(type);
if (!shader) {
throw new Error();
throw new Error(`Unable to create shader type: ${type}. Source: ${source}`);
}
glw.shaderSource(shader, source);
glw.compileShader(shader);
const success = glw.getShaderParameter(shader, glw.COMPILE_STATUS);
const success = !!glw.getShaderParameter(shader, glw.COMPILE_STATUS);
if (success) {
return shader;
}
Expand All @@ -120,12 +120,13 @@ export function createProgram(
) {
const program = glw.createProgram();
if (!program) {
throw new Error();
throw new Error('Unable to create program');
}

glw.attachShader(program, vertexShader);
glw.attachShader(program, fragmentShader);
glw.linkProgram(program);
const success = glw.getProgramParameter(program, glw.LINK_STATUS);
const success = !!glw.getProgramParameter(program, glw.LINK_STATUS);
if (success) {
return program;
}
Expand Down

0 comments on commit 9b7d807

Please sign in to comment.