Crates.io | prototty_glutin |
lib.rs | prototty_glutin |
version | 0.27.0 |
source | src |
created_at | 2018-01-07 21:44:42.058213 |
updated_at | 2019-03-30 10:03:09.080518 |
description | Prototty context for glutin windows. |
homepage | https://github.com/stevebob/prototty.git |
repository | https://github.com/stevebob/prototty.git |
max_upload_size | |
id | 45880 |
size | 43,238 |
A prototty frontend for opengl which uses glutin
for window creation and input. Provides a Context
which can render a view to
a window, and access inputs.
Let's continue the title example started here:
extern crate prototty;
extern crate prototty_glutin;
// Assuming the title and its views were defined here
extern crate prototty_title;
use prototty::{Renderer, inputs};
use prototty_title::*;
fn main() {
// Use a builder to configure how text should be rendered.
// This assumes "Hack-Regular.ttf" is in your "src" directory.
let mut context = prototty_glutin::ContextBuilder::new_with_font(
include_bytes!("Hack-Regular.ttf"))
.with_window_dimensions(320, 240)
.with_font_scale(32.0, 32.0)
.with_cell_dimensions(16, 32)
.with_underline_position(28)
.with_underline_width(2)
.with_max_grid_size(30, 30)
.build().unwrap();
let title = Title {
width: 20,
text: "My Title".to_string(),
};
let mut running = true;
while running {
// render the title using the DemoTitleView
context.render(&DemoTitleView, &title).unwrap();
// exit after the window is closed
context.poll_input(|input| {
if input == inputs::ETX {
running = false;
}
});
}
}
Running this will produce the following output in a new window: