public async Task Initialize() { _context = await _canvasReference.CreateWebGLAsync(new WebGLContextAttributes { PowerPreference = WebGLContextAttributes.POWER_PREFERENCE_HIGH_PERFORMANCE }); vertexBuffer = await _context.CreateBufferAsync(); await _context.BindBufferAsync(BufferType.ARRAY_BUFFER, vertexBuffer); var program = await this.InitProgramAsync(this._context, VS_SOURCE, FS_SOURCE); var positionLocation = await _context.GetAttribLocationAsync(program, "aPos"); var texcoordLocation = await _context.GetAttribLocationAsync(program, "aTex"); await _context.VertexAttribPointerAsync((uint)positionLocation, 3, DataType.FLOAT, false, 6 *sizeof(float), 0); await _context.VertexAttribPointerAsync((uint)texcoordLocation, 2, DataType.FLOAT, false, 6 *sizeof(float), 3 *sizeof(float)); await _context.EnableVertexAttribArrayAsync((uint)positionLocation); await _context.EnableVertexAttribArrayAsync((uint)texcoordLocation); await _context.UseProgramAsync(program); var texture = await _context.CreateTextureAsync(); await _context.BindTextureAsync(TextureType.TEXTURE_2D, texture); }
protected override async Task <WebGLContext> CreateRenderingContextAsync(BECanvasComponent canvas) { var context = await canvas.CreateWebGLAsync(); _program = new AudioFFTGLProgram(context); return(context); }