Guest User

Untitled

a guest
Oct 19th, 2025
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 1.84 KB | None | 0 0
  1. #![allow(
  2.   dead_code,
  3.   unused_variables,
  4.   clippy::too_many_arguments,
  5.   clippy::unnecessary_wraps
  6. )]
  7.  
  8. use anyhow::Result;
  9. use winit::{
  10.   dpi::LogicalSize,
  11.   event::{Event, WindowEvent},
  12.   event_loop::EventLoop,
  13.   window::{Window, WindowAttributes}
  14. };
  15.  
  16. mod sets;
  17. use sets::{V_A, V_A_Data};  
  18.  
  19. struct WE {
  20.   title: String,
  21.   width: i32,
  22.   height: i32,
  23. }
  24.  
  25. impl WE {
  26.   fn new() -> Self {
  27.     Self {
  28.       title: "fucking jesus".to_string(),
  29.       width: 1920,
  30.       height: 1080,
  31.     }
  32.   }
  33. }
  34.  
  35. fn main() -> Result<()> {
  36.   let mut win = WE::new();
  37.   pretty_env_logger::init();
  38.  
  39.   // creating window
  40.   let el = EventLoop::new()?;
  41.   let win_attr = Window::default_attributes()
  42.     .with_title(win.title)
  43.     .with_inner_size(LogicalSize::new(win.width, win.height)
  44.   );
  45.   let mut window = el.create_window(win_attr).unwrap();
  46.  
  47.   // vulkan app struct
  48.   let mut v_a = unsafe { sets::V_A::create(&window)? };
  49.   // previously tried .run_app() from even::EventLoop,
  50.   // and that function needs only one argument,
  51.   // therefore have to figure out later how to
  52.   // rewrite everything with this new .run_app()
  53.   el.run(move |event, elwt| {  
  54.     //print_type_of(&elwt);
  55.     match event {
  56.       // redraw when events are processed
  57.       Event::AboutToWait => window.request_redraw(),
  58.       Event::WindowEvent { event, .. } => match event {
  59.         // redraws frame if v_a aint being destroyed
  60.         WindowEvent::RedrawRequested if !elwt.exiting() => unsafe { v_a.render(&window) }.unwrap(),
  61.         // destroys v_a
  62.         WindowEvent::CloseRequested => {
  63.           elwt.exit();
  64.           unsafe { v_a.destroy(); }
  65.         }
  66.         _ => {}
  67.       }
  68.       _ => {}
  69.     }
  70.   })?;
  71.  
  72.   Ok(())
  73. }
  74.  
  75. // will need when debugging
  76. fn print_type_of<T>(_: &T) {
  77.   println!("variable type is: \n{}", std::any::type_name::<T>());
  78. }
  79.  
Add Comment
Please, Sign In to add comment