From 6ef74275da11e766c2cbe53b676df6188203cae3 Mon Sep 17 00:00:00 2001 From: Bernie Innocenti Date: Sat, 29 Sep 2018 21:13:36 +0900 Subject: [PATCH] Port to glium 0.22 and clutin 0.18 --- Cargo.toml | 7 +++++-- main.rs | 34 +++++++++++++++++----------------- support/camera.rs | 16 +++++++--------- support/vec3.rs | 2 -- 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5698fae..5d8d385 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,8 +1,11 @@ +#cargo-features = ["edition"] + [package] name = "mandelwow" version = "0.7.0" authors = ["Bernie Innocenti "] license = "GPL-3.0+" +#edition = '2018' [profile.release] lto = true @@ -11,8 +14,8 @@ opt-level = 3 [dependencies] cgmath = "*" -glium = "0.21" -glutin = "0.14" +glium = "0.22" +glutin = "0.18" image = { version = "0.18", features = ["png_codec"], optional = true } libxm = "1.0.0" rust-rocket = { path = "rust-rocket", optional = true } diff --git a/main.rs b/main.rs index 02bb86a..175fb61 100644 --- a/main.rs +++ b/main.rs @@ -8,9 +8,8 @@ extern crate glutin; use cgmath::{Euler, Matrix4, Rad, SquareMatrix, Vector3, Vector4, Zero}; use cgmath::conv::array4x4; use glium::{Surface}; -use glutin::ElementState::Pressed; -use glutin::WindowEvent::KeyboardInput; -use glutin::VirtualKeyCode; +use glium::glutin::WindowEvent::KeyboardInput; +use glium::glutin::VirtualKeyCode; use mandelwow_lib::*; use std::f32::consts::PI; use timer::Timer; @@ -65,19 +64,20 @@ pub fn set_main_loop_callback(callback : F) where F : FnMut() -> support::Act fn main() { let mut soundplayer = sound::start(); - let mut events_loop = glutin::EventsLoop::new(); - let window = glutin::WindowBuilder::new() - .with_dimensions(1280, 720) - //.with_fullscreen(glutin::get_primary_monitor()) - .with_title("MandelWow"); - let context = glutin::ContextBuilder::new() - .with_gl_profile(glutin::GlProfile::Core) - .with_depth_buffer(24) + let mut events_loop = glium::glutin::EventsLoop::new(); + let window = glium::glutin::WindowBuilder::new() + //.with_dimensions(1280, 720) + .with_fullscreen(Some(events_loop.get_primary_monitor())); + //.with_title("MandelWow"); + let context = glium::glutin::ContextBuilder::new() + //.with_gl_profile(glutin::GlProfile::Core) + //.with_gl(glutin::GlRequest::Specific(glutin::Api::WebGl, (2, 0))) + //.with_depth_buffer(24) .with_vsync(true); let display = glium::Display::new(window, context, &events_loop).unwrap(); gl_info(&display); - let mut text = text::Text::new(&display, 'A'); +// 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); @@ -181,10 +181,10 @@ fn main() { col: [0., (1. - wave).abs() * 0.5, wave.abs()], }; shaded_cube.draw(&mut frame, &uniforms); - text.model = model * text_pos; +/* 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); @@ -193,14 +193,14 @@ fn main() { let mut action = support::Action::Continue; events_loop.poll_events(|event| { - if let glutin::Event::WindowEvent { event, .. } = event { + if let glium::glutin::Event::WindowEvent { event, .. } = event { camera.process_input(&event); match event { - glutin::WindowEvent::Closed => { + glium::glutin::WindowEvent::CloseRequested => { action = support::Action::Stop }, KeyboardInput { input, .. } => { - if input.state == glutin::ElementState::Pressed { + if input.state == glium::glutin::ElementState::Pressed { if let Some(key) = input.virtual_keycode { match key { VirtualKeyCode::Escape | VirtualKeyCode::Q => { diff --git a/support/camera.rs b/support/camera.rs index b31b9e3..8460197 100644 --- a/support/camera.rs +++ b/support/camera.rs @@ -1,9 +1,7 @@ -extern crate glutin; - use cgmath::{Matrix4, Vector4}; use cgmath::conv::array4x4; -use glutin::WindowEvent::{KeyboardInput, CursorMoved}; -use glutin::VirtualKeyCode; +use glium; +use glium::glutin::VirtualKeyCode; use std::f32; use std::f32::consts::PI; use support::vec3::Vec3; @@ -165,10 +163,10 @@ impl CameraState { //println!("camera_dir = {:?}", self.dir); } - pub fn process_input(&mut self, event: &glutin::WindowEvent) { + pub fn process_input(&mut self, event: &glium::glutin::WindowEvent) { match event { - &CursorMoved { position: (x, y), .. } => { - let (x, y) = (x as i32, y as i32); + &glium::glutin::WindowEvent::CursorMoved { position, .. } => { + let (x, y) = (position.x as i32, position.y as i32); if self.mouse_x == -1 { // Set initial absolute position. self.mouse_x = x; @@ -179,8 +177,8 @@ impl CameraState { self.mouse_x = x; self.mouse_y = y; } - &KeyboardInput { input, .. } => { - let pressed = input.state == glutin::ElementState::Pressed; + &glium::glutin::WindowEvent::KeyboardInput { input, .. } => { + let pressed = input.state == glium::glutin::ElementState::Pressed; let key = match input.virtual_keycode { Some(key) => key, None => return, diff --git a/support/vec3.rs b/support/vec3.rs index a515bde..175c7fd 100644 --- a/support/vec3.rs +++ b/support/vec3.rs @@ -1,5 +1,3 @@ -extern crate glutin; - use std::f32; use std::ops::Add; use std::ops::AddAssign; -- 2.25.1