Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turtle on wayland not working #266

Open
klownie opened this issue Jun 6, 2023 · 13 comments
Open

Turtle on wayland not working #266

klownie opened this issue Jun 6, 2023 · 13 comments

Comments

@klownie
Copy link

klownie commented Jun 6, 2023

I'm running a code using turtle and it seems to not compile because of a Wayland issue I'm guessing.
I'm using arch with newm-atha-git as the wm.
kernel : 6.3.5-zen1-1-zen
with no NVIDIA drivers running.
here's code :

use std::collections::HashMap;
use turtle::Turtle;

fn derive_iter<'a>(þ: &'a mut String, n: usize, p: &Vec<&str>) {
    let mut rules: HashMap<char, String> = HashMap::new();

    for rule in p {
        let parts: Vec<&str> = rule.split("->").map(|s| s.trim()).collect();
        if let [lhs, rhs] = parts.as_slice() {
            let key = lhs.chars().next().unwrap();
            rules.insert(key, rhs.to_string());
        }
    }

    for _ in 0..n {
        let mut deriv_þ = String::new();
        for character in þ.chars() {
            if let Some(rule) = rules.get(&character) {
                deriv_þ.push_str(rule);
            } else {
                deriv_þ.push(character);
            }
        }
        *þ = deriv_þ;
    }
}

fn dessiner(turtle: &mut Turtle, chaine: String, longeur: f64, angle: f64) {
    for character in chaine.chars() {
        match character {
            '+' => turtle.right(angle),
            '-' => turtle.left(angle),
            _ => turtle.forward(longeur),
        }
    }
}

fn main() {
    let mut þ = "F+F+F+F".to_owned();
    let p = vec!["F -> F+f-FF+F+FF+Ff+FF-f+FF-F-FF-Ff-FFF", "f -> ffffff"];
    derive_iter(&mut þ, 1, &p);
    println!("la derive est: {}", þ);

    let mut turtle = Turtle::new();
    turtle.pen_down();
    dessiner(&mut turtle, þ, 15.0, 90.0);
}

here is error traceback :

    Finished dev [unoptimized + debuginfo] target(s) in 0.08s
     Running `target/debug/les-systemes-de-lindenmayer`
la derive est: F+f-FF+F+FF+Ff+FF-f+FF-F-FF-Ff-FFF+F+f-FF+F+FF+Ff+FF-f+FF-F-FF-Ff-FFF+F+f-FF+F+FF+Ff+FF-f+FF-F-FF-Ff-FFF+F+f-FF+F+FF+Ff+FF-f+FF-F-FF-Ff-FFF
thread '<unnamed>' panicked at 'bug: failed to read response from renderer process', /home/klownie/.cargo/registry/src/github.com-1ecc6299db9ec823/turtle-1.0.0-rc.3/src/messenger.rs:41:69
stack backtrace:
interface 'wl_output' has no event 4
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 0, kind: Uncategorized, message: "Success" }', /home/klownie/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.5/src/platf
orm/linux/wayland/event_loop.rs:143:11
stack backtrace:
   0: rust_begin_unwind
             at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/panicking.rs:64:14
   2: core::result::unwrap_failed
             at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/result.rs:1791:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/result.rs:1113:23
   4: winit::platform::platform::wayland::event_loop::EventsLoop::new
             at /home/klownie/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.5/src/platform/linux/wayland/event_loop.rs:126:19
   5: winit::platform::platform::EventsLoop::new_wayland
             at /home/klownie/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.5/src/platform/linux/mod.rs:471:9
   6: winit::platform::platform::EventsLoop::new
             at /home/klownie/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.5/src/platform/linux/mod.rs:442:28
   7: winit::EventsLoop::new
             at /home/klownie/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.19.5/src/lib.rs:251:26
   8: glutin_window::GlutinWindow::new
             at /home/klownie/.cargo/registry/src/github.com-1ecc6299db9ec823/pistoncore-glutin_window-0.63.0/src/lib.rs:114:27
   9: <glutin_window::GlutinWindow as window::BuildFromWindowSettings>::build_from_window_settings
             at /home/klownie/.cargo/registry/src/github.com-1ecc6299db9ec823/pistoncore-glutin_window-0.63.0/src/lib.rs:455:9
  10: window::WindowSettings::build
             at /home/klownie/.cargo/registry/src/github.com-1ecc6299db9ec823/pistoncore-window-0.44.0/src/lib.rs:465:9
  11: <piston_window::PistonWindow<W> as window::BuildFromWindowSettings>::build_from_window_settings
             at /home/klownie/.cargo/registry/src/github.com-1ecc6299db9ec823/piston_window-0.105.0/src/lib.rs:189:47
   0: std::panicking::begin_panic
             at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:607:12
   1: turtle::messenger::read_forever::{{closure}}
             at /home/klownie/.cargo/registry/src/github.com-1ecc6299db9ec823/turtle-1.0.0-rc.3/src/messenger.rs:41:69
   2: core::result::Result<T,E>::map_err
             at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/result.rs:861:27
   3: turtle::messenger::read_forever
             at /home/klownie/.cargo/registry/src/github.com-1ecc6299db9ec823/turtle-1.0.0-rc.3/src/messenger.rs:34:22
   4: turtle::renderer_process::desktop::RendererProcess::new::{{closure}}
             at /home/klownie/.cargo/registry/src/github.com-1ecc6299db9ec823/turtle-1.0.0-rc.3/src/renderer_process/desktop.rs:37:13
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
  12: window::WindowSettings::build
             at /home/klownie/.cargo/registry/src/github.com-1ecc6299db9ec823/pistoncore-window-0.44.0/src/lib.rs:465:9
  13: turtle::renderer::Renderer::run
             at /home/klownie/.cargo/registry/src/github.com-1ecc6299db9ec823/turtle-1.0.0-rc.3/src/renderer.rs:79:40
  14: turtle::server::main
             at /home/klownie/.cargo/registry/src/github.com-1ecc6299db9ec823/turtle-1.0.0-rc.3/src/server.rs:90:5
  15: turtle::server::start
             at /home/klownie/.cargo/registry/src/github.com-1ecc6299db9ec823/turtle-1.0.0-rc.3/src/server.rs:66:9
  16: turtle::turtle_window::TurtleWindow::new
             at /home/klownie/.cargo/registry/src/github.com-1ecc6299db9ec823/turtle-1.0.0-rc.3/src/turtle_window.rs:23:9
  17: turtle::turtle::Turtle::new
             at /home/klownie/.cargo/registry/src/github.com-1ecc6299db9ec823/turtle-1.0.0-rc.3/src/turtle.rs:86:43
  18: les_systemes_de_lindenmayer::main
             at ./src/main.rs:44:22
  19: core::ops::function::FnOnce::call_once
             at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/ops/function.rs:507:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@enaut
Copy link
Contributor

enaut commented Jun 6, 2023

I can confirm that your code as well as the official examples I tried from the repos don't run on Fedora

@enaut
Copy link
Contributor

enaut commented Jun 6, 2023

A solution is to change the glutin version in the Cargo.toml of turtle.rs to 0.28.0. Using an even newer version of glutin requires some more work...

@enaut
Copy link
Contributor

enaut commented Jun 6, 2023

Ups I also had to comment the following lines out:

.with_vsync(true)
.with_double_buffer(Some(true))

@klownie
Copy link
Author

klownie commented Jun 8, 2023

nah it's fine, I just coded the rust turtle with bevy

@enaut
Copy link
Contributor

enaut commented Jun 8, 2023

In two days? not bad - I actually started to rewrite (or rather reinterpret) turtle in bevy - I did not deem it "ready" yet… If I interpret your repositories correctly it is the one to draw the snowflake?

Would you be interested to help in a more general rewrite? If so I'd publish my status and you could give me feedback and contribute? If i recall correctly I had movement, turning, and circles, working (also animated) I was still working on filled shapes but they were also mostly working. I was hoping to do another sprint in August or so to get it polished a little and also to make it simpler to use, as turtle graphics are typically used by absolute beginners.

@enaut
Copy link
Contributor

enaut commented Jun 8, 2023

I just made the repos readable for the public If you would like to join I'd move it to github for better visibility: https://git.teilgedanken.de/Rust/turtlers/

@klownie
Copy link
Author

klownie commented Jun 9, 2023

Your project, @enaut, is truly impressive. Although the repository I created was initially intended for my school homework, please feel free to utilize it for your own purposes.

@klownie
Copy link
Author

klownie commented Jun 9, 2023

Tho @enaut, I dont understand why your are using such an old version of bevy ?

@enaut
Copy link
Contributor

enaut commented Jun 9, 2023

The version of bevy matches the commit time - it was recent back then... I didn't have time to continue for a year.

@klownie
Copy link
Author

klownie commented Jun 10, 2023

@enaut I made my own version (https://github.com/klownie/Burtle) of the bevy turtle but I dont see how we can setup bevy then run some commands before calling .run()

for example being able to run the programme like this :

fn main() {
let mut burtle = Burtle::setup();
burtle.forward(100);
burtle.right(40);
burtle.forward(200);
burtle.run()
}

@enaut
Copy link
Contributor

enaut commented Jun 10, 2023

Yes that was one of the things that need more thought. I thought maybe the init stuff can be put into a macro creating all the extra things that beginners don't need. (like tokio::main)

The other big issue is that turtle is not "finished" meaning when coding for example a hangman game the turtle graphics should be able to react to the inputs... so a run method should not be necessary. Or at least it should not be "final". (Example: https://github.com/pythonanleitung/pythonanleitung.github.io/blob/mdbook/src/bsp/hangman.py)

@klownie
Copy link
Author

klownie commented Jun 11, 2023

ok figured out how to fix it im just stupid

@klownie
Copy link
Author

klownie commented Jun 12, 2023

Here is the implementation of turtle in rust with a script example: https://github.com/klownie/Burtle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants