Created
October 31, 2020 02:07
-
-
Save Abdillah/a562d4bef0db484d5c4497be3b28ea9b to your computer and use it in GitHub Desktop.
Post snippet "Getting Lost in Unsafe Region snippets" on Medium
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Post snippet "Getting Lost in Unsafe Region snippets" on Medium |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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