const SEA_XSIZE: usize = 40;
const SEA_ZSIZE: usize = 25;
-struct World<'a> {
- display: Display,
-
+struct World {
mandelwow_program: Rc<Program>,
mandelwow_bounds: Cube,
mandelwow_bbox: BoundingBox,
bounding_box_enabled: bool,
shaded_cube: ShadedCube,
- text: Text<'a>,
+ text: Text,
sea: [[Vector3<f32>; SEA_ZSIZE]; SEA_XSIZE],
last_hit: f32,
}
-impl<'a> World<'a> {
- pub fn new(display: glium::Display) -> World<'a> {
- let mandelwow_program = Rc::new(mandelwow::program(&display));
- let bounding_box_program = Rc::new(bounding_box::solid_fill_program(&display));
- let shaded_program = Rc::new(shaded_cube::shaded_program(&display));
+impl World {
+ pub fn new(display: &glium::Display) -> World {
+ let mandelwow_program = Rc::new(mandelwow::program(display));
+ let bounding_box_program = Rc::new(bounding_box::solid_fill_program(display));
+ let shaded_program = Rc::new(shaded_cube::shaded_program(display));
// These are the bounds for the 3D slice of the 4D Mandelwow
let mandelwow_bounds = Cube {
World {
mandelwow_program,
mandelwow_bbox: BoundingBox::new(
- &display, &mandelwow_bounds, bounding_box_program.clone()),
+ display, &mandelwow_bounds, bounding_box_program.clone()),
mandelwow_bounds,
bounding_box_enabled: true,
- shaded_cube: ShadedCube::new(&display, shaded_program.clone()),
- text: text::Text::new(&display),
- sea: sea,
+ shaded_cube: ShadedCube::new(display, shaded_program.clone()),
+ text: text::Text::new(display),
+ sea,
hit_time: 0.0,
last_hit: 0.0,
-
- display,
}
}
fn draw_frame(
&self,
+ display: &Display,
camera: &support::camera::CameraState,
t: f32,
) {
//println!("t={} w={:?} camera={:?}", t, w, camera.get_pos());
- let mut frame = self.display.draw();
+ let mut frame = display.draw();
frame.clear_color_and_depth((0.0, 0.0, 0.0, 1.0), 1.0);
let rotation = Matrix4::from(Euler {
}
mandelwow::draw(
- &self.display,
+ &display,
&mut frame,
&self.mandelwow_program,
model,
let display = glium::Display::new(window, context, &event_loop).unwrap();
gl_info(&display);
- let mut world = World::new(display);
+ let mut world = World::new(&display);
let mut timer = Timer::new();
let mut camera = support::camera::CameraState::new();
Event::NewEvents(cause) => {
match cause {
event::StartCause::ResumeTimeReached { .. } | event::StartCause::Init => {
- world.draw_frame(&camera, t);
+ world.draw_frame(&display, &camera, t);
},
_ => {}
}
}
implement_vertex!(Vertex, position, tex_coords);
-pub struct Text<'a> {
+pub struct Text {
tex: texture::Texture2d,
vertex_buffer: glium::VertexBuffer<Vertex>,
index_buffer: glium::IndexBuffer<u16>,
program: glium::Program,
- params: glium::DrawParameters<'a>,
+ params: glium::DrawParameters<'static>,
}
-impl<'a> Text<'a> {
- pub fn new(display: &Display) -> Text<'a> {
+impl Text {
+ pub fn new(display: &Display) -> Text {
let (w, h, pixels) = c64_font();
let image = glium::texture::RawImage2d {
data: std::borrow::Cow::from(pixels),