• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use gpu_display::{GpuDisplay, SurfaceType};
2 
main()3 fn main() {
4     let mut disp = GpuDisplay::open_x(None::<&str>).unwrap();
5     let surface_id = disp
6         .create_surface(None, 1280, 1024, SurfaceType::Scanout)
7         .unwrap();
8 
9     let mem = disp.framebuffer(surface_id).unwrap();
10     for y in 0..1024 {
11         let mut row = [0u32; 1280];
12         for (x, item) in row.iter_mut().enumerate() {
13             let b = ((x as f32 / 1280.0) * 256.0) as u32;
14             let g = ((y as f32 / 1024.0) * 256.0) as u32;
15             *item = b | (g << 8);
16         }
17         mem.as_volatile_slice()
18             .offset(1280 * 4 * y)
19             .unwrap()
20             .copy_from(&row);
21     }
22     disp.flip(surface_id);
23 
24     while !disp.close_requested(surface_id) {
25         disp.dispatch_events().unwrap();
26     }
27 }
28