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 binds to any
//!   windowing library 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 OpenGL resources are `!Send + !Sync`,
//!   preventing cross-thread OpenGL context misuse at compile time.
//! - **FFI Encapsulation & Explicit Safety Invariants:** Every `unsafe` FFI call is encapsulated
//!   behind validated Rust types with explicit `// SAFETY:` comments and
//!   `#![forbid(unsafe_op_in_unsafe_fn)]`.
//! - **Zero Panicking Unwraps:** All fallible operations return [`Result<T>`] (`GlError`),
//!   with clippy denies on `unwrap_used`, `expect_used`, `panic`, `todo`, and `unimplemented`.
//! - **RAII Resource 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 ranges, 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
//!
//! ```no_run
//! use siftgl::{Buffer, BufferDesc, ContextDesc, GlContext};
//!
//! fn main() -> siftgl::Result<()> {
//!     #[cfg(windows)]
//!     {
//!         let gl = GlContext::new_offscreen(&ContextDesc::default())?;
//!         let vbo = Buffer::new(&gl, &BufferDesc::vertex(256))?;
//!         vbo.write_bytes(0, b"hello opengl!")?;
//!         gl.check_error()?;
//!     }
//!     Ok(())
//! }
//! ```

pub mod buffer;
pub mod context;
pub mod debug;
pub mod error;
pub mod framebuffer;
pub mod loader;
pub mod shader;
pub mod sync;
pub(crate) mod sys;
pub mod texture;
pub mod types;
pub mod vao;

// Core re-exports
pub use buffer::{Buffer, BufferDesc, MappedBuffer, MappedBufferMut};
pub use context::{ContextDesc, GlContext};
pub use debug::{DebugGuard, DebugMessage};
pub use error::{GlError, GlErrorCode, Result};
pub use framebuffer::{Framebuffer, Renderbuffer, RenderbufferDesc};
pub use shader::{ActiveAttribute, ActiveUniform, Program, Shader};
pub use sync::{Query, QueryTarget, SyncFence, SyncWaitResult};
pub use texture::{Sampler, SamplerDesc, Texture, Texture2DDesc};
pub use types::{
    AttribLocation, BlendEquation, BlendFactor, BufferStorageFlags, BufferTarget, BufferUsage,
    Capability, ClearColor, ClearMask, CompareFunc, ContextInfo, CullFace, DataType, DebugSeverity,
    DebugSource, DebugType, FramebufferAttachment, FramebufferStatus, FramebufferTarget, FrontFace,
    GlProfile, GlVersion, IndexType, InternalFormat, MemoryBarrierFlags, PixelFormat, PixelType,
    PolygonMode, PrimitiveMode, ScissorRect, ShaderStage, TextureFilter, TextureTarget,
    TextureWrap, UniformLocation, Viewport,
};
pub use vao::{VertexArray, VertexAttribDesc};