Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: how can I check if creating a program shader failed? #53

Open
CodeWithMichal opened this issue Dec 21, 2019 · 2 comments
Open

Comments

@CodeWithMichal
Copy link

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?

@jorolf
Copy link
Contributor

jorolf commented Dec 23, 2019

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.

@aykay76
Copy link

aykay76 commented Dec 27, 2020

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));
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants