ktx-async

Crates.ioktx-async
lib.rsktx-async
version0.1.1
sourcesrc
created_at2019-12-19 02:07:37.367333
updated_at2019-12-20 14:38:09.606623
descriptionAsynchronous reader for KTX texture format
homepage
repositoryhttps://github.com/davll/ktx
max_upload_size
id190462
size102,790
David Lin (davll)

documentation

README

ktx-async

crate-badge docs-badge ci-status

Asynchronous reader for KTX texture format

Features:

  • Asynchronous IO API
  • Works with tokio
  • Supports KTX 1.1

TODO:

  • Custom buffer allocation (ex: OpenGL Pixel Buffer Object)
  • Add std::io::Read support (?)
  • KTX 2.0 (?) spec

Example:

use ktx_async as ktx;
use tokio::fs::File;
use tokio::stream::StreamExt as _;

// In async code

// Open AsyncRead
let file = File::open("example.ktx").await.unwrap();

// Start decoding KTX
let decoder = ktx::Decoder::new(file);
let (info, mut stream) = decoder.read_async().await.unwrap();

// create and bind a texture object ...

// Get all the frames from the stream
while let Some((frame, buf)) = stream.next().await.map(|r| r.unwrap()) {
    unsafe {
        gl::TexImage2D(gl::TEXTURE_2D,
            frame.level as GLint,
            info.gl_internal_format as GLint,
            frame.pixel_width as GLsizei,
            frame.pixel_height as GLsizei,
            /*border*/ 0,
            info.gl_format as GLenum,
            info.gl_type as GLenum,
            buf.as_ptr() as *const GLvoid);
    }
}

Development

Build:

cargo build

Run Test:

cargo test

Run Example:

cargo run --example basic

License

This project is licensed under the MIT License

References

Commit count: 22

cargo fmt