I wanted to make an app with rust but all
i made are cli application. I did tried to
use bevy but it always give out errors.
So is there any std graphics library in
rust?
(post deleted by author)
First off, welcome... but also, you are not owed a reply by anyone.
Your question is lacking substance and you are coming off as somewhat rude and entitled, so I wouldn't expect people to immediately want to help you.
You say Bevy gave you errors. What errors did it give you? Learning and using rust is often an exercise in getting and interpreting error messages, and then applying the advice it gives you.
Bevy is quite powerful and would help you quite a bit more than a lower level API might.
And to answer your question directly. No, there is not an std::graphics that will magically render what you want.
This all depends on your use case though. What are you trying to make. A 2D game? 3D? a simple GUI?
What you should use depends greatly on this and when you ask questions like this, it is best to give as much detail as possible.
If you do this, people will be much more inclined to help you.
Sorry for that @chris_r , did not want to be rude ; really sorry. But am trying to make something 2d, for now to i just want to draw a window , i don't really
know any other library than bevy but i would like to use something else.
You could give ggez a try.
thank you really much @firebits.io
Rust standard library generally tries to be small, and avoids doing things that aren't obvious things available on most platforms.
The standard library officially doesn't even have random number generation. You won't find any graphics there. The expectation is that all Rust uses will use crates-io dependencies for most things (better search is on https://lib.rs)
If you want something basic for games, see
Thanks i will search for both of these.
so i tried Macroquad and when i runned it it did nothing
here is my code by the way :
use macroquad::prelude::*;
#[macroquad::main("BasicShapes")]
async fn main() {
loop {
clear_background(RED);
draw_line(40.0, 40.0, 100.0, 200.0, 15.0, BLUE);
draw_rectangle(screen_width() / 2.0 - 60.0, 100.0, 120.0, 60.0, GREEN);
draw_circle(screen_width() - 30.0, screen_height() - 30.0, 15.0, YELLOW);
draw_text("IT WORKS!", 20.0, 20.0, 30.0, DARKGRAY);
next_frame().await
}
}
maybe i should use wasm
wait it gave an error at the end : ( yassine@DESKTOP-3T5O6FE:/mnt/c/spider man/game$ cargo run
Finished dev
profile [unoptimized + debuginfo] target(s) in 1.86s
Running target/debug/game
thread 'main' panicked at /home/yassine/.cargo/registry/src/index.crates.io-6f17d22bba15001f/miniquad-0.4.6/src/native/linux_x11.rs:577:13:
XOpenDisplay() failed!
note: run with RUST_BACKTRACE=1
environment variable to display a backtrace)
It looks like you are using WSL. Do other GUI applications work when started from there?
NO @Bruecki
should i use a real distro
WSL does support graphical applications these days, but you need to install the graphical libraries (X11, qt, gtk, sdl or whatever your GUI crate is building on) for applications that need them. I think most WSL distros don't have the desktop packages and their deps preinstalled.
Finally ,it works thank you all for helping me making a graphical,
I am ready to start my apps
As others have noted, rust doesn't have a std graphics library. Like many, I've also struggled with a number of libraries during my learning/development process. Some of this is inevitable as the rapid pace of developing/improving rust itself, leads to a rapid pace of development/improvement in many crates/libraries. I've played around at various times with wgpu, winit, bevy, and arrayfire (working on some neural net ideas). The rapid pace of development also means that many new features are often poorly documented and any online tutorials that are available are out-of-date within 6-12 months. That is what we get for living on the "bleeding edge."
The best bevy tutorial I've found on YouTube is this one: https://www.youtube.com/watch?v=B6ZFuYYZCSY&list=PL2wAo2qwCxGDp9fzBOTy_kpUTSwM1iWWd . However, it is three versions old and the latest bevy (0.15.3) has made significant changes. I'd recommend setting bevy version to 0.12.1 and going through the tutorial. It will give you a good base. Then I'd switch to the newest bevy version (0.15.3 as of this comment) and adopt your code to work in the newer bevy. That approach helped me retain an understanding of the principles while adjusting to the newer bevy syntax. Personally I hate tutorials that do nothing more than present someone typing in their code without much/any explanation, and this tutorial is definitely different from that.
The many bevy examples on github (bevy/examples at latest · bevyengine/bevy · GitHub) will be helpful to go through, once you've completed the tutorial and read the bevy QuickStart tutorial (Introduction). Good luck with your development.