summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-04-29 15:46:59 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-04-29 15:46:59 +0300
commit62c9d42e112ba7a532e790d982ec4b959ef55386 (patch)
tree0697ae23b70c01a9e6bc2c03c0813432ec9b6221 /src/main.rs
first commitHEADmaster
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
new file mode 100644
index 0000000..ca110bb
--- /dev/null
+++ b/src/main.rs
@@ -0,0 +1,74 @@
+use ash::Entry;
+use ash::Instance;
+use ash::vk;
+use ash_window::create_surface;
+use raw_window_handle::HasDisplayHandle;
+use raw_window_handle::HasWindowHandle;
+use winit::application::ApplicationHandler;
+use winit::event::WindowEvent;
+use winit::event_loop::{ActiveEventLoop, EventLoop};
+use winit::window::{Window, WindowId};
+
+#[derive(Default)]
+struct App {
+ window: Option<Window>,
+ entry: Option<Entry>,
+ vk_instance: Option<Instance>,
+}
+
+impl ApplicationHandler for App {
+ fn window_event(
+ &mut self,
+ event_loop: &ActiveEventLoop,
+ window_id: WindowId,
+ event: WindowEvent,
+ ) {
+ match event {
+ WindowEvent::CloseRequested => {
+ event_loop.exit();
+ }
+ WindowEvent::RedrawRequested => {
+ println!("Redraw requested!");
+ }
+ WindowEvent::Resized(e) => {
+ println!("Received resize event, {:?}", event);
+ println!("New size: {:?}", e);
+ }
+ _ => {
+ println!("Received event: {:?}", event);
+ }
+ }
+ }
+ fn resumed(&mut self, event_loop: &ActiveEventLoop) {
+ println!("Idk ig the app wants me to resume??");
+ let win = event_loop
+ .create_window(Window::default_attributes())
+ .unwrap();
+ unsafe {
+ self.entry = Some(Entry::load().unwrap());
+ let app_info = vk::ApplicationInfo {
+ api_version: vk::make_api_version(0, 1, 0, 0),
+ ..Default::default()
+ };
+ let create_info = vk::InstanceCreateInfo {
+ p_application_info: &app_info,
+ ..Default::default()
+ };
+ self.vk_instance = Some(self.entry.as_ref().unwrap().create_instance(&create_info, None).unwrap());
+ let _ = create_surface(
+ &self.entry.as_ref().unwrap(),
+ &self.vk_instance.as_ref().unwrap(),
+ win.display_handle().unwrap().as_raw(),
+ win.window_handle().unwrap().as_raw(),
+ None,
+ );
+ };
+ self.window = Some(win);
+ }
+}
+
+fn main() {
+ let event_loop = EventLoop::new().unwrap();
+ event_loop.set_control_flow(winit::event_loop::ControlFlow::Wait);
+ let _ = event_loop.run_app(&mut App::default());
+}