BlazorExtensions/Canvas

WebGL: INVALID_OPERATION: drawArrays: no valid shader program in use

jameskolts opened this issue · 0 comments

I was simply following the initial documentation to see a trivial example of the canvas in action with WebGL. The provided code throws an Invalid Operation exception with the following message: CanvasContextManager.ts:77 WebGL: INVALID_OPERATION: drawArrays: no valid shader program in use. This error is visible in the browser console and causes the canvas to render as purely black screen.

public partial class GameCanvas 
{
    private WebGLContext _context;

    protected BECanvasComponent _canvasReference;

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        _context = await _canvasReference.CreateWebGLAsync();

        await _context.ClearColorAsync(0, 0, 0, 1);


        await _context.BeginBatchAsync();
        await _context.ClearAsync(BufferBits.COLOR_BUFFER_BIT);
        await _context.DrawArraysAsync(Primitive.TRIANGLES, 0, 3);

        await _context.EndBatchAsync();
    }
}