WebGLazor 1.0.1
dotnet add package WebGLazor --version 1.0.1
NuGet\Install-Package WebGLazor -Version 1.0.1
<PackageReference Include="WebGLazor" Version="1.0.1" />
<PackageVersion Include="WebGLazor" Version="1.0.1" />
<PackageReference Include="WebGLazor" />
paket add WebGLazor --version 1.0.1
#r "nuget: WebGLazor, 1.0.1"
#:package WebGLazor@1.0.1
#addin nuget:?package=WebGLazor&version=1.0.1
#tool nuget:?package=WebGLazor&version=1.0.1
WebGLazor
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#.
Table of Contents
- Key Features
- API Reference
- Package requirements
- Installation
- Quick Start
- License
- Third-Party Libraries
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
pinnedmemory 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.
- WebGLCanvas Component: Setup and event handling.
- WebGL 2.0 Implementation: Detailed method signatures and usage.
- Constants: Enumeration of all WebGL 2.0 constants.
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
Add the Namespace: Add
using WebGLazor;to your_Imports.razor.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); } }Constants: Use WebGL constants from
WebGLConstsclass, 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 | Versions 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. |
-
net10.0
- Microsoft.AspNetCore.Components.Web (>= 10.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
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.