Crates.io | ktx-async |
lib.rs | ktx-async |
version | 0.1.1 |
source | src |
created_at | 2019-12-19 02:07:37.367333 |
updated_at | 2019-12-20 14:38:09.606623 |
description | Asynchronous reader for KTX texture format |
homepage | |
repository | https://github.com/davll/ktx |
max_upload_size | |
id | 190462 |
size | 102,790 |
Asynchronous reader for KTX texture format
Features:
TODO:
std::io::Read
support (?)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);
}
}
Build:
cargo build
Run Test:
cargo test
Run Example:
cargo run --example basic
This project is licensed under the MIT License