From d07efa5c89d262fec815fcc5a92cc50860bb886e Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 4 Jun 2024 00:39:26 +0200 Subject: [PATCH] Now using schedule_update (https://github.com/not-fl3/miniquad/pull/437) But some debuging needed because it works not as expected (Because mouse or finger movements now not redraw) --- Cargo.lock | 16 +++++++++------- Cargo.toml | 6 +++++- src/main.rs | 43 ++++++++++++++++++++++++++++++++++++++----- 3 files changed, 52 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 985e0b2..1359bc3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -101,9 +101,9 @@ dependencies = [ [[package]] name = "glam" -version = "0.21.3" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "518faa5064866338b013ff9b2350dc318e14cc4fcd6cb8206d7e7c9886c98815" +checksum = "9e05e7e6723e3455f4818c7b26e855439f7546cf617ef669d1adedb8669e5cb9" [[package]] name = "hashbrown" @@ -136,8 +136,9 @@ checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" [[package]] name = "macroquad" -version = "0.4.5" -source = "git+https://github.com/birhburh/macroquad.git?branch=less_fps#92584c983f283d469b6e67bb6fa8008a9d418eab" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7007a706b920b69dc57ee73c15370e417cfc5be12abd5f5f3d3adca9571ad97" dependencies = [ "bumpalo", "fontdue", @@ -152,7 +153,8 @@ dependencies = [ [[package]] name = "macroquad_macro" version = "0.1.7" -source = "git+https://github.com/birhburh/macroquad.git?branch=less_fps#92584c983f283d469b6e67bb6fa8008a9d418eab" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5cecfede1e530599c8686f7f2d609489101d3d63741a6dc423afc997ce3fcc8" [[package]] name = "malloc_buf" @@ -172,8 +174,8 @@ dependencies = [ [[package]] name = "miniquad" -version = "0.4.0" -source = "git+https://github.com/birhburh/miniquad.git?branch=less_fps#e53441e08b1509053ac7fc50037be40b5cb0fe48" +version = "0.4.2" +source = "git+https://github.com/not-fl3/miniquad.git#833799ec32883cdd7465a5f8ddc80e2203dbcbc4" dependencies = [ "libc", "ndk-sys", diff --git a/Cargo.toml b/Cargo.toml index c30714f..6b996a7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,4 +8,8 @@ label = "MACROQUAD TIC-TAC-TOE" min_sdk_version = 26 [dependencies] -macroquad = { git = "https://github.com/birhburh/macroquad.git", branch = "less_fps" } +macroquad = { version = "0.4.7" } + +[patch.crates-io] +# miniquad = { path = "../miniquad"} +miniquad = { git = "https://github.com/not-fl3/miniquad.git" } diff --git a/src/main.rs b/src/main.rs index cc83d7c..27e4a1d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,38 @@ use macroquad::prelude::*; -use macroquad::request_redraw; + +fn window_conf() -> Conf { + Conf { + window_title: "TicTacToe".to_owned(), + platform: miniquad::conf::Platform { + blocking_event_loop: true, + // apple_gfx_api: miniquad::conf::AppleGfxApi::Metal, + ..Default::default() + }, + ..Default::default() + } +} + +// #[macroquad::main(window_conf)] +// async fn main() { +// let mut timer_frames = 0; +// let mut frame = 0; +// macroquad::miniquad::window::schedule_update(); +// loop { +// info!("Frame updated: {}", frame); +// frame += 1; +// clear_background(LIGHTGRAY); +// if macroquad::ui::root_ui().button(None, "Test") { +// info!("Button pressed"); +// timer_frames = 50; +// } +// if timer_frames != 0 { +// timer_frames -= 1; +// draw_rectangle(0.0, 100.0, timer_frames as f32 * 20.0, 60.0, GREEN); +// macroquad::miniquad::window::schedule_update(); +// } +// next_frame().await +// } +// } const SQUARES: i16 = 3; @@ -87,7 +120,7 @@ fn check_end(fields: &Vec>) -> bool { false } -#[macroquad::main("TicTacToe")] +#[macroquad::main(window_conf)] async fn main() { let mut fields = vec![None; (SQUARES * SQUARES) as usize]; let mut game_over = false; @@ -178,13 +211,13 @@ async fn main() { left -= 1; if left <= 0 { game_over = true; - request_redraw(); + macroquad::miniquad::window::schedule_update(); } } prev = None; if check_end(&fields) { game_over = true; - request_redraw(); + macroquad::miniquad::window::schedule_update(); } } @@ -276,7 +309,7 @@ async fn main() { } x_move = true; left = SQUARES * SQUARES; - request_redraw(); + macroquad::miniquad::window::schedule_update(); } }