Skip to content

Commit

Permalink
Render some state as text #1
Browse files Browse the repository at this point in the history
  • Loading branch information
aeplay committed Jun 7, 2016
1 parent 2d8e659 commit 8af777a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions citybound/src/main.rs
Expand Up @@ -12,13 +12,15 @@ mod simulation;

fn main() {
let (to_simulation, from_renderer) = channel::<()>();
let (to_renderer, from_simulation) = channel::<()>();
let (to_renderer, from_simulation) = channel::<String>();

let renderer_listener = move |past: &models::State, future: &models::State| {
match from_renderer.try_recv() {
Ok(_) => {
println!("creating renderer state...");
to_renderer.send(()).unwrap();
to_renderer.send(
format!("Simulation frame: {}", past.core.header.ticks)
).unwrap();
},
Err(_) => {}
};
Expand Down
2 changes: 1 addition & 1 deletion citybound/src/models.rs
Expand Up @@ -2,7 +2,7 @@ use world_record::{ID, FutureState, FutureRecordCollection, GrowableBuffer};
use std::path::PathBuf;
// use std::ops::Range;

#[derive(Default)]
#[derive(Default, Clone)]
pub struct Core {
pub ticks: u64,
pub time: f64
Expand Down
4 changes: 2 additions & 2 deletions monet/src/lib.rs
Expand Up @@ -7,7 +7,7 @@ use glium::Surface;

use std::sync::mpsc::{Sender, Receiver};

pub fn main_loop (prepare_frame: Sender<()>, data_provider: Receiver<()>) {
pub fn main_loop (prepare_frame: Sender<()>, data_provider: Receiver<String>) {
use glium::DisplayBuild;

let window = glutin::WindowBuilder::new()
Expand Down Expand Up @@ -93,7 +93,7 @@ pub fn main_loop (prepare_frame: Sender<()>, data_provider: Receiver<()>) {
target.clear_color(0.0, 0.0, 0.0, 0.0);
target.draw(&vertex_buffer, &index_buffer, &program, &uniforms, &Default::default()).unwrap();

let text = glium_text::TextDisplay::new(&text_system, &font, "The city sim you deserve.");
let text = glium_text::TextDisplay::new(&text_system, &font, new_data.as_str());
let text_matrix = [
[0.05, 0.0, 0.0, 0.0],
[0.0, 0.05, 0.0, 0.0],
Expand Down

0 comments on commit 8af777a

Please sign in to comment.