Expand description
Webglue: WebGL2 wrapper for Rust and WebAssembly
This library provides an OpenGL-like API for WebAssembly/Browser environments.
This crate is WASM-only and must be compiled with --target wasm32-unknown-unknown.
§Features
- 59 GL functions implemented (buffers, shaders, textures, uniforms, drawing)
- Handle-based registry - Translates u32 IDs to glow’s opaque handles
- Instanced rendering - DrawElementsInstanced for high-performance rendering
- Matrix math library - Perspective, lookAt, rotate, translate, scale
- Optional GLTF loading - Load and render GLTF/GLB models
§Usage
ⓘ
// This crate requires wasm32 target
use webglue as gl;
unsafe {
// Initialize once with WebGL2 context
gl::init_with_webgl2_context(webgl2_context);
// Use standard GL calls
let mut vbo = 0;
gl::GenBuffers(1, &mut vbo);
gl::BindBuffer(gl::ARRAY_BUFFER, vbo);
// ... rest of your WebGL code
}Re-exports§
Modules§
Functions§
- Active
Texture ⚠ - Attach
Shader ⚠ - Bind
Buffer ⚠ - Bind
Framebuffer ⚠ - Bind
Renderbuffer ⚠ - Bind
Texture ⚠ - Bind
Vertex ⚠Array - Blend
Func ⚠ - Blend
Func ⚠Separate - Buffer
Data ⚠ - Buffer
SubData ⚠ - Check
Framebuffer ⚠Status - Clear⚠
- Clear
Color ⚠ - Compile
Shader ⚠ - Create
Program ⚠ - Create
Shader ⚠ - Delete
Buffers ⚠ - Delete
Program ⚠ - Delete
Shader ⚠ - Delete
Textures ⚠ - Delete
Vertex ⚠Arrays - Depth
Mask ⚠ - Disable⚠
- Disable
Vertex ⚠Attrib Array - Draw
Arrays ⚠ - Draw
Elements ⚠ - Draw
Elements ⚠Instanced - Enable⚠
- Enable
Vertex ⚠Attrib Array - Finish⚠
- Framebuffer
Renderbuffer ⚠ - Framebuffer
Texture2D ⚠ - GenBuffers⚠
- GenFramebuffers⚠
- GenRenderbuffers⚠
- GenTextures⚠
- GenVertex
Arrays ⚠ - Generate
Mipmap ⚠ - GetError⚠
- GetGraphics
Reset ⚠Status - GetIntegerv⚠
- GetProgram
Info ⚠Log - GetProgramiv⚠
- GetShader
Info ⚠Log - GetShaderiv⚠
- GetString⚠
- GetStringi⚠
- GetUniform
Location ⚠ - Link
Program ⚠ - Pixel
Storei ⚠ - Point
Size ⚠ - PointSize - Set point sprite size (not supported in WebGL2, use shader)
- Read
Pixels ⚠ - ReadPixels - Read pixels from framebuffer (stub - use browser APIs instead)
- Renderbuffer
Storage ⚠ - Shader
Source ⚠ - TexImage2D⚠
- TexParameteri⚠
- TexSub
Image2D ⚠ - Uniform1f⚠
- Uniform1i⚠
- Uniform2f⚠
- Uniform3f⚠
- Uniform3fv⚠
- Uniform3fv - Set vec3 array uniform (stub)
- Uniform4f⚠
- Uniform4fv⚠
- Uniform4fv - Set vec4 array uniform (stub)
- Uniform
Matrix3fv ⚠ - Set 3x3 matrix uniform (mat3) Used for normal transforms in lighting calculations
- Uniform
Matrix4fv ⚠ - Set 4x4 matrix uniform (mat4) Critical for 3D transforms: Model-View-Projection matrices From gl-rs patterns for matrix uniforms
- UseProgram⚠
- Vertex
Attrib ⚠Divisor - Vertex
Attrib ⚠Pointer - Viewport⚠
- init_
with_ ⚠context - Initialize the GL context (must be called once from WASM entry point)
- load_
with - Stub for gl::load_with - no-op since glow context is already initialized This is re-exported from mod.rs but duplicated here for completeness