Browse Source

Remove some println calls

Johannes Hofmann 8 years ago
parent
commit
78d7b41aee
4 changed files with 14 additions and 21 deletions
  1. 14
    17
      src/main.rs
  2. 0
    2
      src/map_view_gl.rs
  3. 0
    1
      src/tile_cache.rs
  4. 0
    1
      src/tile_loader.rs

+ 14
- 17
src/main.rs View File

38
 #[cfg(target_os = "android")]
38
 #[cfg(target_os = "android")]
39
 android_start!(main);
39
 android_start!(main);
40
 
40
 
41
-fn resize_callback(width: u32, height: u32) {
42
-    println!("Window resized to {}x{}", width, height);
43
-}
44
-
45
 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
41
 #[derive(Copy, Clone, Debug, PartialEq, Eq)]
46
 enum Action {
42
 enum Action {
47
     Nothing,
43
     Nothing,
171
 
167
 
172
     let mut window = glutin::WindowBuilder::new().build().unwrap();
168
     let mut window = glutin::WindowBuilder::new().build().unwrap();
173
     window.set_title(&("DeltaMap - ".to_string() + sources.current_name()));
169
     window.set_title(&("DeltaMap - ".to_string() + sources.current_name()));
174
-    window.set_window_resize_callback(Some(resize_callback as fn(u32, u32)));
175
-    let _ = unsafe { window.make_current() };
176
 
170
 
177
-    let proxy = window.create_window_proxy();
171
+    //TODO Find a safe way to trigger a redraw from a resize callback.
172
+    //TODO The callback is only allowed to access static content.
173
+    window.set_window_resize_callback(None);
178
 
174
 
175
+    let _ = unsafe { window.make_current() };
179
     let cx = context::Context::from_window(&window);
176
     let cx = context::Context::from_window(&window);
180
-    let mut map = map_view_gl::MapViewGl::new(
181
-        &cx,
182
-        window.get_inner_size_pixels().unwrap(),
183
-        move || { proxy.wakeup_event_loop(); },
184
-    );
177
+
178
+    let mut map = {
179
+        let proxy = window.create_window_proxy();
180
+
181
+        map_view_gl::MapViewGl::new(
182
+            &cx,
183
+            window.get_inner_size_pixels().unwrap(),
184
+            move || { proxy.wakeup_event_loop(); },
185
+        )
186
+    };
185
 
187
 
186
     let mut input_state = InputState {
188
     let mut input_state = InputState {
187
         mouse_position: (0, 0),
189
         mouse_position: (0, 0),
193
     let mut last_draw = Instant::now();
195
     let mut last_draw = Instant::now();
194
 
196
 
195
     'outer: for event in window.wait_events() {
197
     'outer: for event in window.wait_events() {
196
-        let mut start_loop = Instant::now();
197
         let start_source_id = sources.current().id();
198
         let start_source_id = sources.current().id();
198
 
199
 
199
         let mut redraw = false;
200
         let mut redraw = false;
221
             if diff + draw_dur * 2 < milli16 {
222
             if diff + draw_dur * 2 < milli16 {
222
                 if let Some(dur) = milli16.checked_sub(draw_dur * 2) {
223
                 if let Some(dur) = milli16.checked_sub(draw_dur * 2) {
223
                     std::thread::sleep(dur);
224
                     std::thread::sleep(dur);
224
-                    println!("SLEEP {}", dur.as_secs() as f64 + f64::from(dur.subsec_nanos()) * 1e-9);
225
 
225
 
226
                     for event in window.poll_events() {
226
                     for event in window.poll_events() {
227
                         match handle_event(event, &mut map, &mut input_state, &mut sources) {
227
                         match handle_event(event, &mut map, &mut input_state, &mut sources) {
244
             let _ = window.swap_buffers();
244
             let _ = window.swap_buffers();
245
 
245
 
246
             last_draw = Instant::now();
246
             last_draw = Instant::now();
247
-
248
-            let diff = start_loop.elapsed();
249
-            println!("EVENT LOOP SECS {}", diff.as_secs() as f64 + f64::from(diff.subsec_nanos()) * 1e-9);
250
         }
247
         }
251
 
248
 
252
         // set window title
249
         // set window title

+ 0
- 2
src/map_view_gl.rs View File

27
     pub fn new<F>(cx: &Context, initial_size: (u32, u32), update_func: F) -> MapViewGl
27
     pub fn new<F>(cx: &Context, initial_size: (u32, u32), update_func: F) -> MapViewGl
28
         where F: Fn() + Sync + Send + 'static,
28
         where F: Fn() + Sync + Send + 'static,
29
     {
29
     {
30
-        println!("version: {}", cx.gl_version());
31
-        println!("max texture size: {}", cx.max_texture_size());
32
         unsafe {
30
         unsafe {
33
             let mut program = Program::from_paths(cx, "shader/map.vert", "shader/map.frag");
31
             let mut program = Program::from_paths(cx, "shader/map.vert", "shader/map.frag");
34
 
32
 

+ 0
- 1
src/tile_cache.rs View File

66
             }
66
             }
67
 
67
 
68
             self.map.insert(t, img);
68
             self.map.insert(t, img);
69
-            println!("CACHE SIZE: {} tiles", self.map.len());
70
         }
69
         }
71
 
70
 
72
         let tile = Tile::new(tile_coord, source.id());
71
         let tile = Tile::new(tile_coord, source.id());

+ 0
- 1
src/tile_loader.rs View File

164
                     let ele: Option<TileRequest> = queue.lock().ok().and_then(|mut q| q.pop());
164
                     let ele: Option<TileRequest> = queue.lock().ok().and_then(|mut q| q.pop());
165
 
165
 
166
                     if let Some(request) = ele {
166
                     if let Some(request) = ele {
167
-                        println!("thread {}: queue {:?} {:?}", thread_id, request.tile, request.path);
168
                         if client_opt.is_none() {
167
                         if client_opt.is_none() {
169
                             client_opt = Client::builder().build().ok();
168
                             client_opt = Client::builder().build().ok();
170
                         }
169
                         }