Canvas
Canvas copied to clipboard
Question: how can I check if creating a program shader failed?
Hi,
I am trying to rewrite some examples from webgl documentation and seems like I fail at the very beginning :) I am trying to check whether creating a program shader failed or not. The example JS code should looke similar to:
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
alert('An error occurred compiling the shaders: ' + gl.getShaderInfoLog(shader));
}
But in your C# implementation of GetShaderParameterAsync it require generic parameter and I can't figure out what it should be. Could someone explain?
The generic parameter should be the type you expect the method to return.
As you can see here the method returns a bool
when you pass COMPILE_STATUS
.
In Blazor you can use something like:
bool status = await _context.GetShaderParameterAsync<bool>(shader, ShaderParameter.COMPILE_STATUS);
if (status == false)
{
throw new Exception(await _context.GetShaderInfoLogAsync(shader));
}