Skip to content

Instantly share code, notes, and snippets.

@bvssvni
Created November 1, 2014 01:05
Show Gist options
  • Save bvssvni/63ed1bbb05bc7834604d to your computer and use it in GitHub Desktop.
Save bvssvni/63ed1bbb05bc7834604d to your computer and use it in GitHub Desktop.
/// Calls closure with a texture constructor enabled.
/// This is required to render characters.
pub fn with_texture_constructor<'a>(&mut self, texture_constructor: TextureConstructor<'a, T>, f: |&mut UiContext<T>|) {
use std::mem::transmute;
self.glyph_cache.texture_constructor =
Some(unsafe { transmute(texture_constructor) });
f(self);
self.glyph_cache.texture_constructor = None;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment