texture-cache 0.1.0

A LRU texture cache for caching many small textures in a single big GPU texture
Documentation
  • Coverage
  • 100%
    33 out of 33 items documented1 out of 18 items with examples
  • Size
  • Source code size: 28.78 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.14 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Rodrigodd/texture-cache
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Rodrigodd

Texture Cache

A LRU texture cache for caching many small textures in a single big texture, which is stored in GPU. This is used to cache textures that are rendered at runtime and change constantly, like glyph text rendering.

This is basically a generic implementation of glyph_brush_draw_cache, excluding the rendering part and letting you to hook your own rendering.

Usage

Create a LruTextureCache and add rects by passing mutable slice of RectEntry to the method cache_rects. A stored Rect can be queried from the cache by passing it key to the method get_rect. Rect and RectEntry can contain arbitrary data that could be useful for rendering from/to the texture cache.

After passing the slice to cache_rects, it will be reorder so that it start with every rect that was added to the cache.

use texture_cache::{LruTextureCache, RectEntry};

let mut rects = vec![RectEntry { width: 20, height: 20, key: "my_rect", value: (), entry_data: ()}];
let mut cache = LruTextureCache::new(256, 256);
let result = cache.cache_rects(&mut rects)?;

for rect in rects[0..result.len()] {
    let cached_rect = cache.get_rect(&rect.key);
    // Draw the rect to the texture cache...
}

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.