What is the best way for drawing graphics with Rust for university

My course includes tasks like drawing a line, rotating a rectangle, rendering different 3D shapes and so on. It seems like I'll also need to write a bit of OpenGL at the end. SDL seemed relatively difficult to install for me.

One alternative you might want to try is compiling to WebAssembly and using WebGL. I've always found browser based demos to be more accessible than something that needs to be compiled and run natively.

Here's an example of using WebGL from Rust.

AreWeGameYet also has a page on 3D renderers.

1 Like

Edit: just saw you want 3D,not 2D

I haven't used either myself, but you could try

  • piet, which wraps multiple non-Rust 2D drawing libraries like Direct2D and cairo and exposes a common API for them or
  • andrew, which is a pure-rust 2D drawing library which doesn't require any system libraries but is probably less powerful

You also can use vulkano using examples as a starting point. I had zero Vulkan knowledge and a bit of experience working with OpenGL, it took me several days to write a custom point cloud render and online visualization of camera feed. Note that initial compilation time will be quite long, since by default it will compile shaderc under the hood, if you want to save time I recommend to install pre-compiled version.

There is also wgpu-rs, which probably will become a de-facto standard of doing GPU accelerated graphics in Rust (it's a higher-level API than Vulkan, so it's more convenient at the cost of losing some degree of control), but I haven't worked with it.

2 Likes

I've used wgpu-rs, and it's pretty simple and clean as far as Vulkan-like APIs go. It's largely undocumented, and as someone who hasn't ever done any serious graphics programming, I would not recommend it (or any Vulkan-like API) to a beginner unless they were serious about learning it. Most of the Vulkan tutorials assume you already know everything about OpenGL et al.

That being said, this nvidia page was a major eye-opener for me, though I had to stare at it for a few minutes to figure out what they're trying to say. In general, Vulkan things are not written for beginners.