Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #![allow(
- dead_code,
- unused_variables,
- clippy::too_many_arguments,
- clippy::unnecessary_wraps
- )]
- use anyhow::Result;
- use winit::{
- dpi::LogicalSize,
- event::{Event, WindowEvent},
- event_loop::EventLoop,
- window::{Window, WindowAttributes}
- };
- mod sets;
- use sets::{V_A, V_A_Data};
- struct WE {
- title: String,
- width: i32,
- height: i32,
- }
- impl WE {
- fn new() -> Self {
- Self {
- title: "fucking jesus".to_string(),
- width: 1920,
- height: 1080,
- }
- }
- }
- fn main() -> Result<()> {
- let mut win = WE::new();
- pretty_env_logger::init();
- // creating window
- let el = EventLoop::new()?;
- let win_attr = Window::default_attributes()
- .with_title(win.title)
- .with_inner_size(LogicalSize::new(win.width, win.height)
- );
- let mut window = el.create_window(win_attr).unwrap();
- // vulkan app struct
- let mut v_a = unsafe { sets::V_A::create(&window)? };
- // previously tried .run_app() from even::EventLoop,
- // and that function needs only one argument,
- // therefore have to figure out later how to
- // rewrite everything with this new .run_app()
- el.run(move |event, elwt| {
- //print_type_of(&elwt);
- match event {
- // redraw when events are processed
- Event::AboutToWait => window.request_redraw(),
- Event::WindowEvent { event, .. } => match event {
- // redraws frame if v_a aint being destroyed
- WindowEvent::RedrawRequested if !elwt.exiting() => unsafe { v_a.render(&window) }.unwrap(),
- // destroys v_a
- WindowEvent::CloseRequested => {
- elwt.exit();
- unsafe { v_a.destroy(); }
- }
- _ => {}
- }
- _ => {}
- }
- })?;
- Ok(())
- }
- // will need when debugging
- fn print_type_of<T>(_: &T) {
- println!("variable type is: \n{}", std::any::type_name::<T>());
- }
Add Comment
Please, Sign In to add comment