siftgl 0.1.0

Memory-safe, ergonomic, zero-dependency, security-hardened OpenGL 3.3-4.6 Core frontend for Rust
Documentation
  • Coverage
  • 100%
    572 out of 572 items documented1 out of 231 items with examples
  • Size
  • Source code size: 245.8 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 4.6 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • omrcooking

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), or OpenGL.framework (macOS) using native OS dynamic linking, or integrates with any windowing library (winit/glutin, glfw, sdl2) via GlContext::from_loader. Includes built-in headless WGL Core Profile context creation (GlContext::new_offscreen) on Windows.
  • Compile-Time Thread Affinity: GlContext and all GPU objects are !Send + !Sync, enforcing OpenGL's thread-local context affinity at compile time.
  • FFI Encapsulation & Explicit Safety Invariants: Every unsafe FFI 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 on unwrap_used, expect_used, panic, todo, and unimplemented.
  • RAII Lifecycle & Teardown Ordering: Every GPU object (Buffer, Shader, Program, VertexArray, Texture, Sampler, Framebuffer, Renderbuffer, SyncFence, Query, DebugGuard) is deterministically destroyed on Drop, 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 on Buffer, WGL sentinel pointer filtering (0/1/2/3/-1), interior-NUL string rejection, and panic-safe catch_unwind C FFI trampolines for KHR_debug callbacks.

Quick Start

use siftgl::{Buffer, BufferDesc, ContextDesc, GlContext};

fn main() -> siftgl::Result<()> {
    let gl = GlContext::new_offscreen(&ContextDesc::default())?;
    let vbo = Buffer::new(&gl, &BufferDesc::vertex(256))?;
    vbo.write_bytes(0, b"hello opengl!")?;

    let mut readback = [0u8; 13];
    vbo.read_bytes(0, &mut readback)?;
    assert_eq!(&readback, b"hello opengl!");
    gl.check_error()?;
    Ok(())
}

License

Dual-licensed under either of:

at your option.