Line 48... |
Line 48... |
let mut vbindex = 0;
|
let mut vbindex = 0;
|
// TODO: streaming suited vertexbuffer.
|
// TODO: streaming suited vertexbuffer.
|
// Docs say to use dynamic, persistent might be GL4?
|
// Docs say to use dynamic, persistent might be GL4?
|
let mut vertex_buffer : glium::VertexBuffer =
|
let mut vertex_buffer : glium::VertexBuffer =
|
glium::VertexBuffer::empty_dynamic(&window, vbmax).unwrap();
|
glium::VertexBuffer::empty_dynamic(&window, vbmax).unwrap();
|
|
// Possible todo: add line support, perhaps modulated
|
|
// by beam trace speed.
|
let indices = glium::index::NoIndices(
|
let indices = glium::index::NoIndices(
|
glium::index::PrimitiveType::Points);
|
glium::index::PrimitiveType::Points);
|
|
|
let vertex_shader_src = r#"
|
let vertex_shader_src = r#"
|
#version 140
|
#version 140
|
Line 65... |
Line 67... |
gl_Position = vec4(position, 0.0, 1.0);
|
gl_Position = vec4(position, 0.0, 1.0);
|
}
|
}
|
}
|
}
|
"#;
|
"#;
|
|
|
// TODO: falloff, blending?
|
|
// Should use a uniform to indicate current time
|
// Should use a uniform to indicate current time
|
// Possibly add a timestamp per lit dot?
|
// Possibly add a timestamp per lit dot?
|
let fragment_shader_src = r#"
|
let fragment_shader_src = r#"
|
#version 140
|
#version 140
|
in float age;
|
in float age;
|
Line 93... |
Line 94... |
.. Default::default()
|
.. Default::default()
|
};
|
};
|
|
|
let t0 = time::get_time();
|
let t0 = time::get_time();
|
|
|
|
use std::sync::mpsc::{channel, Receiver};
|
|
let verts : Receiver = (|| {
|
|
use std::thread::spawn;
|
|
|
|
let (tx, rx) = channel();
|
|
spawn(move || {
|
|
loop {
|
|
let now = (time::get_time() - t0)
|
|
.num_microseconds().unwrap() as f32;
|
|
let mut str = String::new();
|
|
std::io::stdin().read_line(&mut str).unwrap();
|
|
// FIXME: Parse line.
|
|
let mut words = str.split_whitespace();
|
|
let x = words.next().unwrap().parse().unwrap();
|
|
let y = words.next().unwrap().parse().unwrap();
|
|
let v = Vertex {position: [x, y], time: now };
|
|
tx.send(v).unwrap();
|
|
//println!("Vertex: {:?}", [x,y]);
|
|
}
|
|
});
|
|
rx
|
|
})();
|
|
|
loop {
|
loop {
|
for event in window.poll_events() {
|
for event in window.poll_events() {
|
// Simplest nowait: use poll_events()
|
// Simplest nowait: use poll_events()
|
match event {
|
match event {
|
glium::glutin::Event::Closed => {
|
glium::glutin::Event::Closed => {
|
Line 120... |
Line 144... |
rng.next_f32()*2.0-1.0],
|
rng.next_f32()*2.0-1.0],
|
time: now });
|
time: now });
|
vbindex = (vbindex+1) % vbmax;
|
vbindex = (vbindex+1) % vbmax;
|
}
|
}
|
// TODO: Read points from e.g. stdin
|
// TODO: Read points from e.g. stdin
|
for _ in 0..30 {
|
for v in verts.try_iter() {
|
let mut str = String::new();
|
//println!("Vertex: {:?} {} {}",
|
std::io::stdin().read_line(&mut str).unwrap();
|
// v.position, v.time, now);
|
// FIXME: Parse line.
|
wvb.set(vbindex, v);
|
let mut words = str.split_whitespace();
|
|
let x = words.next().unwrap().parse().unwrap();
|
|
let y = words.next().unwrap().parse().unwrap();
|
|
|
|
wvb.set(vbindex,
|
|
Vertex {position: [x, y], time: now });
|
|
vbindex = (vbindex+1) % vbmax;
|
vbindex = (vbindex+1) % vbmax;
|
}
|
}
|
}
|
}
|
|
|
// Closing the window closes the program.
|
// Closing the window closes the program.
|