Skip to content

adamuso/Blazor.WebGL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blazor.WebGL

Library for Blazor wrapping the WebGL methods for 3D rendering in canvas.

Usage

Add to your _ViewImports.cshtml.

@using Blazor.WebGL
@addTagHelper *, Blazor.WebGL

Use the component.

@inherits TestProject.MyComponent

<WebGLCanvas ref="@Canvas"/>

Get the WebGLContext and use it for your needs.

namespace TestProject
{
    public class MyComponent : BlazorComponent
    {
        protected WebGLCanvas Canvas { get; set; }

        protected override void OnAfterRender()
        {
            var context = Canvas.Context;

            context.ClearColor(new Color(0.5f, 0.5f, 0.5f, 1));
            context.Enable(WebGLOption.DEPTH_TEST);
            context.DepthFunction(DepthFunction.LEQUAL);
            context.Clear(ClearBuffer.COLOR_BUFFER_BIT | ClearBuffer.DEPTH_BUFFER_BIT);
        }
    }
}

Building

You will need:

Open repository in VS Code. Use Ctrl+Shift+B to run build task and choose build - Blazor.WebGL task.

You are ready to go! Now go and build examples.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published