-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
1,255 additions
and
36 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ members = [ | |
"wafel_viz_demo", | ||
"wafel_viz_tests", | ||
"wafel_viz", | ||
"wafel_window", | ||
] | ||
resolver = "2" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[package] | ||
name = "wafel_window" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
chrono = "0.4.29" | ||
wgpu = { workspace = true } | ||
winit = "0.28.6" | ||
once_cell = "1.18.0" | ||
tracing = "0.1.37" | ||
tracing-log = "0.1.3" | ||
tracing-subscriber = "0.3.17" | ||
pollster = "0.3.0" | ||
image = { version = "0.24.7", optional = true } | ||
egui = "0.22.0" | ||
egui-wgpu = "0.22.0" | ||
egui-winit = "0.22.0" | ||
hot-lib-reloader = "0.6.5" | ||
wafel_viz = { path = "../wafel_viz", features = ["wgpu"], optional = true } | ||
static_assertions = "1.1.0" | ||
|
||
[dev-dependencies] | ||
wafel_api = { path = "../wafel_api" } | ||
|
||
[[example]] | ||
name = "sm64" | ||
required-features = ["wafel_viz"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// This prevents the console window from appearing on Windows in release mode. | ||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] | ||
|
||
use wafel_window::Config; | ||
|
||
fn main() { | ||
let config = Config::new().with_title("Minimal example"); | ||
|
||
wafel_window::run(&config, move |env| { | ||
let ctx = env.egui_ctx(); | ||
|
||
egui::CentralPanel::default().show(ctx, |ui| { | ||
ui.label(format!("{:#?}", env.config())); | ||
ui.label(format!("{:.3} mspf = {:.1} fps", env.mspf(), env.fps())); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] | ||
|
||
use std::time; | ||
|
||
use wafel_api::{Game, Input}; | ||
use wafel_viz::{ObjectCull, VizConfig}; | ||
use wafel_window::Config; | ||
|
||
fn main() { | ||
let mut game = unsafe { Game::new("libsm64/sm64_us") }; | ||
|
||
for frame in 0..1400 { | ||
if frame % 2 == 1 { | ||
game.write("gControllerPads[0].button", game.constant("START_BUTTON")); | ||
} | ||
game.advance(); | ||
} | ||
let mut last_update_time = time::Instant::now(); | ||
|
||
let mut a_down = false; | ||
let mut b_down = false; | ||
let mut stick_x: i8 = 0; | ||
let mut stick_y: i8 = 0; | ||
|
||
let config = Config::new(); | ||
wafel_window::run(&config, move |env| { | ||
let ctx = env.egui_ctx(); | ||
|
||
if last_update_time.elapsed().as_secs_f32() >= 1.0 / 30.0 { | ||
last_update_time = time::Instant::now(); | ||
|
||
let mut buttons = 0; | ||
if a_down { | ||
buttons |= game.constant("A_BUTTON").as_int() as u16; | ||
} | ||
if b_down { | ||
buttons |= game.constant("B_BUTTON").as_int() as u16; | ||
} | ||
game.set_input(Input { | ||
buttons, | ||
stick_x, | ||
stick_y, | ||
}); | ||
|
||
game.advance(); | ||
} | ||
|
||
egui::CentralPanel::default().show(ctx, |ui| { | ||
ui.label(format!("{:.3} mspf = {:.1} fps", env.mspf(), env.fps())); | ||
ui.label(format!("frame = {}", game.frame())); | ||
|
||
ui.checkbox(&mut a_down, "A"); | ||
ui.checkbox(&mut b_down, "B"); | ||
ui.add(egui::Slider::new(&mut stick_x, -127..=127).text("X")); | ||
ui.add(egui::Slider::new(&mut stick_y, -127..=127).text("Y")); | ||
|
||
let rect = ui.available_rect_before_wrap(); | ||
|
||
if rect.width() as u32 > 0 && rect.height() as u32 > 0 { | ||
let render_data = game.render(&VizConfig { | ||
screen_top_left: [rect.left() as u32, rect.top() as u32], | ||
screen_size: [rect.width() as u32, rect.height() as u32], | ||
object_cull: ObjectCull::ShowAll, | ||
..Default::default() | ||
}); | ||
|
||
env.draw_viz(render_data); | ||
} | ||
}); | ||
}); | ||
} |
Oops, something went wrong.