Changing the lifetime of glium::DrawParameters to 'static did the trick.
Poof! No need carry around lifetime annotations everywhere.
Also removed Display from World, which paves the way for rendering World
onto multiple displays at once (think VR or video streaming...)
const SEA_XSIZE: usize = 40;
const SEA_ZSIZE: usize = 25;
const SEA_XSIZE: usize = 40;
const SEA_ZSIZE: usize = 25;
-struct World<'a> {
- display: Display,
-
mandelwow_program: Rc<Program>,
mandelwow_bounds: Cube,
mandelwow_bbox: BoundingBox,
bounding_box_enabled: bool,
shaded_cube: ShadedCube,
mandelwow_program: Rc<Program>,
mandelwow_bounds: Cube,
mandelwow_bbox: BoundingBox,
bounding_box_enabled: bool,
shaded_cube: ShadedCube,
sea: [[Vector3<f32>; SEA_ZSIZE]; SEA_XSIZE],
sea: [[Vector3<f32>; SEA_ZSIZE]; SEA_XSIZE],
-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 {
// These are the bounds for the 3D slice of the 4D Mandelwow
let mandelwow_bounds = Cube {
World {
mandelwow_program,
mandelwow_bbox: BoundingBox::new(
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,
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,
hit_time: 0.0,
last_hit: 0.0,
}
}
fn draw_frame(
&self,
}
}
fn draw_frame(
&self,
camera: &support::camera::CameraState,
t: f32,
) {
camera: &support::camera::CameraState,
t: f32,
) {
//println!("t={} w={:?} camera={:?}", t, w, camera.get_pos());
//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 {
frame.clear_color_and_depth((0.0, 0.0, 0.0, 1.0), 1.0);
let rotation = Matrix4::from(Euler {
&mut frame,
&self.mandelwow_program,
model,
&mut frame,
&self.mandelwow_program,
model,
let display = glium::Display::new(window, context, &event_loop).unwrap();
gl_info(&display);
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();
let mut timer = Timer::new();
let mut camera = support::camera::CameraState::new();
Event::NewEvents(cause) => {
match cause {
event::StartCause::ResumeTimeReached { .. } | event::StartCause::Init => {
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);
}
implement_vertex!(Vertex, position, tex_coords);
tex: texture::Texture2d,
vertex_buffer: glium::VertexBuffer<Vertex>,
index_buffer: glium::IndexBuffer<u16>,
program: glium::Program,
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),
let (w, h, pixels) = c64_font();
let image = glium::texture::RawImage2d {
data: std::borrow::Cow::from(pixels),