コード例 #1
0
ファイル: GLShader.cs プロジェクト: sonicmouse/BlazorAudioFFT
        public virtual async Task <GLShader> CreateFromResourceAsync(string resourceName)
        {
            ResetObject();

            var shader = await _context.CreateShaderAsync(_shaderType);

            await _context.ShaderSourceAsync(shader, await ResourceLoader.LoadAsTextAsync(resourceName));

            await _context.CompileShaderAsync(shader);

            if (!await _context.GetShaderParameterAsync <bool>(shader, ShaderParameter.COMPILE_STATUS))
            {
                LastError = await _context.GetShaderInfoLogAsync(shader);

                LastState = LastStateType.Failed;
                return(this);
            }

            await _context.AttachShaderAsync(_program, shader);

            LastState     = LastStateType.Success;
            GLObjectValue = shader;

            return(this);
        }
コード例 #2
0
        private async Task <WebGLShader> LoadShaderAsync(WebGLContext gl, ShaderType type, string source)
        {
            var shader = await gl.CreateShaderAsync(type);

            await gl.ShaderSourceAsync(shader, source);

            await gl.CompileShaderAsync(shader);

            if (!await gl.GetShaderParameterAsync <bool>(shader, ShaderParameter.COMPILE_STATUS))
            {
                string info = await gl.GetShaderInfoLogAsync(shader);

                await gl.DeleteShaderAsync(shader);

                throw new Exception("An error occured while compiling the shader: " + info);
            }

            return(shader);
        }