siftgl 0.1.0

Memory-safe, ergonomic, zero-dependency, security-hardened OpenGL 3.3-4.6 Core frontend for Rust
Documentation
# 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

```rust
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:

- MIT license ([LICENSE-MIT]LICENSE-MIT)
- Apache License, Version 2.0 ([LICENSE-APACHE]LICENSE-APACHE)

at your option.