WebGLazor 1.0.1

dotnet add package WebGLazor --version 1.0.1
                    
NuGet\Install-Package WebGLazor -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="WebGLazor" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="WebGLazor" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="WebGLazor" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add WebGLazor --version 1.0.1
                    
#r "nuget: WebGLazor, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package WebGLazor@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=WebGLazor&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=WebGLazor&version=1.0.1
                    
Install as a Cake Tool

WebGLazor

https://github.com/github/docs/actions/workflows/main.yml GitHub NuGet version NuGet downloads

WebGLazor is a high-performance, low-level WebGL 2.0 binding library for Blazor WebAssembly. It provides a direct, zero-copy interface to the pure WebGL 2.0 API, enabling developers to build hardware-accelerated 2D and 3D graphics applications completely in C#.

NuGet Package | Live Demo


Table of Contents


Key Features

Maximum Performance with Zero-Copy

WebGLazor is engineered for speed. It utilizes direct memory access to the WebAssembly heap, allowing C# Span<T> and arrays to be passed directly to WebGL without the overhead of data marshaling or serialization.

  • Direct Memory Access: Uses pinned memory pointers for buffer and texture operations.
  • Zero Allocations: Rendering loops are designed to run with zero garbage collection pressure.
  • Fast Interop: Optimized internal mappings bypass the standard Blazor JS interop overhead for critical paths.

Full WebGL 2.0 API Coverage

WebGLazor exposes the entire WebGL 2.0 standard.

  • Advanced Rendering: VAOs, Uniform Buffer Objects (UBOs), Transform Feedback, and Multi-Render Targets (MRT).
  • Textures: Support for 3D textures, 2D Array textures, and immutable texture storage.
  • State Management: Complete control over Samplers, Sync Objects, and Query objects.
  • Shaders: Full GLSL shader support with strict typing for shader sources and precision formats.

Developer Friendly

  • Strong Typing: All WebGL constants and enums are strongly typed to prevent invalid state usage.
  • Blazor Component: Includes the <WebGLCanvas> component for instant setup.
  • Context Management: Built-in support for multiple WebGL contexts and automatic context loss handling.

AOT & Trimming

  • WebGLazor is AOT-compatible and trimming safe, ensuring optimal performance in production builds.

API Reference

For a complete and detailed reference of all available classes, methods, and constants, please read the API Reference Wiki.


Package requirements

This package uses Microsoft.AspNetCore.Components.Web package:

.NET Version Required Package
.NET 10.0 Microsoft.AspNetCore.Components.Web ≥ 10.0.0

Installation

Install the package via NuGet:

dotnet add package WebGLazor

Add package reference

<PackageReference Include="WebGLazor" Version="*" />

Quick Start

  1. Add the Namespace: Add using WebGLazor; to your _Imports.razor.

  2. Use the Component: Add the canvas to your page and handle the context creation.

    <WebGLCanvas Width="800" Height="600" OnContextCreated="OnContextCreated" />
    
    @code {
        private WebGLContext _gl;
    
        private void OnContextCreated(WebGLContext gl)
        {
            _gl = gl;
    
            // Set clear color to black, fully opaque
            _gl.ClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    
            // Clear the color buffer with specified clear color
            _gl.Clear(WebGLConsts.COLOR_BUFFER_BIT);
        }
    }
    
  3. Constants: Use WebGL constants from WebGLConsts class, e.g., WebGLConsts.COLOR_BUFFER_BIT.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Third-Party Libraries

See the NOTICE file for attribution information.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 304 1/18/2026
1.0.0 86 1/18/2026

Updated library initialization logic in `WebGLContext`. The path to `webglazor.js` is now generated dynamically using `NavigationManager.BaseUri`. This allows the library to automatically detect the correct application base address, making it more flexible for different hosting scenarios.