Skip to content

Instantly share code, notes, and snippets.

@Abdillah
Created October 31, 2020 02:07
Show Gist options
  • Save Abdillah/a562d4bef0db484d5c4497be3b28ea9b to your computer and use it in GitHub Desktop.
Save Abdillah/a562d4bef0db484d5c4497be3b28ea9b to your computer and use it in GitHub Desktop.
Post snippet "Getting Lost in Unsafe Region snippets" on Medium
pgr.draw(viewport::Viewport {
rect: [ 0, 0, w as i32, h as i32 ],
draw_size: [ w as u32, h as u32 ],
window_size: [ w.into(), h.into() ],
}, |c, pgr| {
use graphics::*;
let mut glycache = opengl_graphics::GlyphCache::new("./assets/fonts/FiraCode-Regular.ttf", (), opengl_graphics::TextureSettings::new()).unwrap();
unsafe { gl::Enable(gl::TEXTURE_2D); };
text::Text::new_color(WHITE, fontsize)
.draw(
"H",
&mut glycache,
&DrawState::default(),
c.transform.trans(100.0, 200.0),
pgr
).unwrap();
unsafe { gl::Disable(gl::TEXTURE_2D); };
});
windowed_context.swap_buffers().unwrap();
Post snippet "Getting Lost in Unsafe Region snippets" on Medium
pgr.draw(viewport::Viewport {
rect: [ 0, 0, w as i32, h as i32 ],
draw_size: [ w as u32, h as u32 ],
window_size: [ w.into(), h.into() ],
}, |c, pgr| {
use graphics::*;
let mut glycache = opengl_graphics::GlyphCache::new("./assets/fonts/FiraCode-Regular.ttf", (), opengl_graphics::TextureSettings::new()).unwrap();
unsafe { gl::Enable(gl::TEXTURE_2D); };
text::Text::new_color(WHITE, fontsize)
.draw(
"H",
&mut glycache,
&DrawState::default(),
c.transform.trans(100.0, 200.0),
pgr
).unwrap();
unsafe { gl::Disable(gl::TEXTURE_2D); };
});
windowed_context.swap_buffers().unwrap();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment