siftgl
A memory-safe, ergonomic, zero-dependency, security-hardened OpenGL 3.3–4.6 Core frontend for Rust.
siftgl brings the safety and ergonomics philosophy of siftx12 and siftvulkan to OpenGL:
- Zero Third-Party Dependencies: Directly loads
opengl32.dll(Windows),libGL.so.1(Linux), orOpenGL.framework(macOS) using native OS dynamic linking, or integrates with any windowing library (winit/glutin,glfw,sdl2) viaGlContext::from_loader. Includes built-in headless WGL Core Profile context creation (GlContext::new_offscreen) on Windows. - Compile-Time Thread Affinity:
GlContextand all GPU objects are!Send + !Sync, enforcing OpenGL's thread-local context affinity at compile time. - FFI Encapsulation & Explicit Safety Invariants: Every
unsafeFFI call is confined behind validated Rust types with explicit// SAFETY:comments and#![forbid(unsafe_op_in_unsafe_fn)]. - Zero Panicking Unwraps: All fallible operations return
siftgl::Result<T>(GlError), with clippy denies onunwrap_used,expect_used,panic,todo, andunimplemented. - RAII Lifecycle & Teardown Ordering: Every GPU object (
Buffer,Shader,Program,VertexArray,Texture,Sampler,Framebuffer,Renderbuffer,SyncFence,Query,DebugGuard) is deterministically destroyed onDrop, keeping the dispatch table and native context alive until the last object drops. - Security & Bounds Hardening: Checked integer arithmetic on all byte offsets/sizes, pixel buffer length validation on texture uploads and
read_pixels, double-map prevention onBuffer, WGL sentinel pointer filtering (0/1/2/3/-1), interior-NUL string rejection, and panic-safecatch_unwindC FFI trampolines forKHR_debugcallbacks.
Quick Start
use ;
License
Dual-licensed under either of:
- MIT license (LICENSE-MIT)
- Apache License, Version 2.0 (LICENSE-APACHE)
at your option.