#![allow(dead_code)] #![allow(unused_imports)] #![allow(unused_variables)] #![allow(unused_unsafe)] use std::{collections::HashMap, time::Instant}; use sdl2::{ controller::{Axis, Button, GameController}, event::Event as SDLEvent, GameControllerSubsystem, Sdl, }; use wgpu::Backend; use winit::{ event::{ElementState, Event, KeyboardInput, VirtualKeyCode, WindowEvent}, event_loop::ControlFlow, }; use crate::{ ffi::{SpecialKey, WindowSize}, gpu::{create_depth_texture, create_render_texture, initialize_gpu, DeviceHolder}, imgui::{initialize_imgui, ImGuiState}, shaders::render_into_pass, }; mod gpu; mod imgui; mod imgui_backend; mod shaders; mod util; mod zeus; #[cxx::bridge(namespace = "aurora")] mod ffi { unsafe extern "C++" { include!("aurora.hpp"); pub(crate) type AppDelegate; } unsafe extern "C++" { include!("lib.hpp"); pub(crate) fn App_onAppLaunched(cb: Pin<&mut AppDelegate>); pub(crate) fn App_onAppIdle(cb: Pin<&mut AppDelegate>, dt: f32) -> bool; pub(crate) fn App_onAppDraw(cb: Pin<&mut AppDelegate>); pub(crate) fn App_onAppPostDraw(cb: Pin<&mut AppDelegate>); pub(crate) fn App_onAppWindowResized(cb: Pin<&mut AppDelegate>, size: &WindowSize); pub(crate) fn App_onAppWindowMoved(cb: Pin<&mut AppDelegate>, x: i32, y: i32); pub(crate) fn App_onAppExiting(cb: Pin<&mut AppDelegate>); // Input pub(crate) fn App_onCharKeyDown(cb: Pin<&mut AppDelegate>, code: u8, is_repeat: bool); pub(crate) fn App_onCharKeyUp(cb: Pin<&mut AppDelegate>, code: u8); pub(crate) fn App_onSpecialKeyDown( cb: Pin<&mut AppDelegate>, key: SpecialKey, is_repeat: bool, ); pub(crate) fn App_onSpecialKeyUp(cb: Pin<&mut AppDelegate>, key: SpecialKey); // Controller pub(crate) fn App_onControllerButton( cb: Pin<&mut AppDelegate>, idx: u32, button: ControllerButton, pressed: bool, ); pub(crate) fn App_onControllerAxis( cb: Pin<&mut AppDelegate>, idx: u32, axis: ControllerAxis, value: i16, ); } pub struct Window { pub(crate) inner: Box, } pub struct WindowSize { pub width: u32, pub height: u32, } #[derive(Debug)] pub enum Backend { Invalid, Vulkan, Metal, D3D12, D3D11, OpenGL, WebGPU, } pub enum ElementState { Pressed, Released, } pub enum MouseButton { Left, Right, Middle, Other, } pub enum SpecialKey { None = 0, F1 = 1, F2 = 2, F3 = 3, F4 = 4, F5 = 5, F6 = 6, F7 = 7, F8 = 8, F9 = 9, F10 = 10, F11 = 11, F12 = 12, Esc = 13, Enter = 14, Backspace = 15, Insert = 16, Delete = 17, Home = 18, End = 19, PgUp = 20, PgDown = 21, Left = 22, Right = 23, Up = 24, Down = 25, Tab = 26, } pub struct KeyboardInput { pub scancode: u32, pub state: ElementState, // pub } pub enum ControllerButton { A, B, X, Y, Back, Guide, Start, LeftStick, RightStick, LeftShoulder, RightShoulder, DPadUp, DPadDown, DPadLeft, DPadRight, Other, MAX, } pub enum ControllerAxis { LeftX, LeftY, RightX, RightY, TriggerLeft, TriggerRight, MAX, } pub struct Icon { pub data: Vec, pub width: u32, pub height: u32, } extern "Rust" { type WindowContext; type App; fn app_run(mut delegate: UniquePtr, icon: Icon); fn get_args() -> Vec; fn get_window_size() -> WindowSize; fn set_window_title(title: &CxxString); fn get_dxt_compression_supported() -> bool; fn get_backend() -> Backend; fn get_backend_string() -> &'static str; fn set_fullscreen(v: bool); } } impl From