gl-capture

Crates.iogl-capture
lib.rsgl-capture
version0.0.2
sourcesrc
created_at2023-05-24 21:44:40.492872
updated_at2023-05-25 01:12:11.087369
descriptionCapture screenshot in OpenGL
homepage
repositoryhttps://github.com/vallentin/gl-capture
max_upload_size
id873778
size21,945
Christian Vallentin (vallentin)

documentation

https://docs.rs/gl-capture

README

gl-capture

Latest Version Docs License

Library for capturing screenshots in OpenGL.

See examples/basic.rs for a complete example.

let img = unsafe { gl_capture::capture() };
// img.size: (u32, u32)
// img.data: Vec<capture_gl::Rgb>
// Now use e.g. `png` or `image` crate to save the image data to a file

Alternatively, use capture_into() to reuse the same image data, instead of reallocating on every call.

let mut img = gl_capture::RgbImageData::new(size);
unsafe {
    gl_capture::capture_into(&mut img);
}
// img.size: (u32, u32)
// img.data: Vec<capture_gl::Rgb>

Also supports other formats, e.g. RgbaImageData, BgrImageData, BgraImageData.

When manually using gl::ReadPixels(), instead it is also possible to use read_pixels() or read_pixels_ptr(), which performs some additional checks and setup.

let format = gl_capture::CaptureFormat::Rgb;
let mut data = format.allocate_pixel_data(size);

unsafe {
    gl_capture::read_pixels((0, 0), size, format, &mut data);
}
Commit count: 5

cargo fmt