gl_info(&display);
- let text = text::Text::new(&display);
+ let mut text = text::Text::new(&display, 'A');
let mandelwow_program = mandelwow::program(&display);
let bounding_box_program = bounding_box::solid_fill_program(&display);
let shaded_program = shaded_cube::shaded_program(&display);
let mandelwow_bbox = bounding_box::BoundingBox::new(&display, &bounds, &bounding_box_program);
let shaded_cube = ShadedCube::new(&display, &shaded_program);
- const SEA_XSIZE: usize = 24;
- const SEA_ZSIZE: usize = 20;
- let sea_xmin = -14.0f32;
- let sea_xmax = 14.0f32;
+ const SEA_XSIZE: usize = 40;
+ const SEA_ZSIZE: usize = 25;
+ let sea_xmin = -20.0f32;
+ let sea_xmax = 20.0f32;
let sea_y = -2.5;
let sea_zmin = -2.0f32;
- let sea_zmax = -26.0f32;
+ let sea_zmax = -27.0f32;
let sea_xstep = (sea_xmax - sea_xmin) / (SEA_XSIZE as f32);
let sea_zstep = (sea_zmax - sea_zmin) / (SEA_ZSIZE as f32);
+ println!("xstep={} ystep={:?}", sea_xstep, sea_zstep);
let mut sea = [[Vector3::zero(); SEA_ZSIZE]; SEA_XSIZE];
for x in 0..SEA_XSIZE {
mandelwow_bbox.draw(&mut frame, &uniforms);
}
+ let text_rot = Matrix4::from_angle_x(cgmath::Deg(-90.0f32));
+ let text_pos = Matrix4::from_translation(Vector3 { x: 0.0, y: 0.501, z: 0.0f32}) * text_rot;
for x in 0..SEA_XSIZE {
for z in 0..SEA_ZSIZE {
let wave = ((x as f32 / SEA_XSIZE as f32 * PI * 5.0 + t * 2.0).sin() +
(z as f32 / SEA_ZSIZE as f32 * PI * 3.0 + t * 3.0).sin()) * 0.3;
- let model = Matrix4::from_translation(sea[x][z] + Vector3 {x: 0., y: wave, z: 0.});
+ let model = Matrix4::from_translation(
+ sea[x][z] + Vector3 {x: 0., y: wave, z: 0.});
let uniforms = uniform! {
model: array4x4(model),
perspview: perspview,
col: [0., (1. - wave).abs() * 0.5, wave.abs()],
};
shaded_cube.draw(&mut frame, &uniforms);
+ text.model = model * text_pos;
+ text.character = (x + z * SEA_XSIZE) as u8 as char;
+ text.draw(&mut frame, &perspview);
}
}
mandelwow::draw(&display, &mut frame, &mandelwow_program, model, &camera, &bounds, wow);
- text.draw(&mut frame, &perspview);
-
frame.finish().unwrap();
for ev in display.poll_events() {
use cube::Cube;
use glium;
use glium::index::PrimitiveType;
-use glium::Surface;
+use glium::{Display, Program, Surface};
use support;
-
/*
fn mand(cx: f32, cy: f32) -> [f32; 3] {
let maxiter = 64;
}
*/
-pub fn program(display: &glium::Display) -> glium::Program {
+pub fn program(display: &Display) -> Program {
Program::from_source(
display,
include_str!("shaders/mandelwow.vert"),
.unwrap()
}
-fn mandel<U>(display: &glium::Display,
+fn mandel<U>(display: &Display,
frame: &mut glium::Frame,
- program: &glium::Program,
+ program: &Program,
uniforms: &U,
bounds: &Cube,
z: [f32; 2]) where U: glium::uniforms::Uniforms {
frame.draw(&vb, &indices, program, uniforms, ¶ms).unwrap();
}
-pub fn draw(display: &glium::Display,
+pub fn draw(display: &Display,
mut frame: &mut glium::Frame,
- program: &glium::Program,
+ program: &Program,
model: [[f32; 4]; 4],
camera: &support::camera::CameraState,
bounds: &Cube,
index_buffer: glium::IndexBuffer<u16>,
program: glium::Program,
params: glium::DrawParameters<'a>,
- model: Matrix4<f32>,
+ pub model: Matrix4<f32>,
+ pub character: char,
}
impl<'a> Text<'a> {
- pub fn new(display: &Display) -> Text {
+ pub fn new(display: &Display, character: char) -> Text {
let (w, h, pixels) = c64_font();
let image = glium::texture::RawImage2d {
data: std::borrow::Cow::from(pixels),
display,
&[
Vertex {
- position: [-1.0, -1.0],
+ position: [-0.5, -0.5],
tex_coords: [0.0, 1.0],
},
Vertex {
- position: [-1.0, 1.0],
+ position: [-0.5, 0.5],
tex_coords: [0.0, 0.0],
},
Vertex {
- position: [1.0, 1.0],
+ position: [0.5, 0.5],
tex_coords: [1.0, 0.0],
},
Vertex {
- position: [1.0, -1.0],
+ position: [0.5, -0.5],
tex_coords: [1.0, 1.0],
},
],
};
Text {
- model: Matrix4::from_translation(Vector3::unit_z() * (-1.0)),
tex: tex,
vertex_buffer: vertex_buffer,
index_buffer: index_buffer,
program: text_program(display),
params: params,
+ model: Matrix4::from_translation(Vector3::unit_z() * (-1.0)),
+ character: character,
}
}
perspview: *perspview,
tex: self.tex.sampled()
.magnify_filter(glium::uniforms::MagnifySamplerFilter::Nearest),
- index: 'C' as i32,
+ index: self.character as i32,
// RGB values from http://unusedino.de/ec64/technical/misc/vic656x/colors/
bgcolor: srgb([ 64, 50, 133u8]), // 6 - blue
fgcolor: srgb([120, 106, 189u8]), // 14 - light blue