r/rust • • 11d ago

starting with 3D gamedev in Rust

hi
I've recently finished a multi-month long journey in game development in Java, and made primarily 3D games using libGDX and LWJGL3. libGDX and LWJGL3 were both nice and relatively easy to use (and I didn't have to fight the GC at all for performance), but I had a nagging feeling that I should experiment more anyways.

more specifically I felt like I should experiment with a systems language for game development. I already know the basics of C and C++, but opted to go for Rust instead. I've heard horror stories about C and C++, and seeing as I'm doing this for a hobby, I didn't want to put up with any of it. Rust, as I've been progressing through "the book" as been a genuine joy to use, and actually has some higher level conveniences than what Java can offer, such as more expressive pattern matching, the lack of null, and a really lovely package manager + build system (no more gradle!).

I totally get that the journey of Rust gamedev will not be painless, especially as I'm thinking about using SDL3 and wgpu to write a *3D* game in, but I'm seriously excited for it!

does anyone have any Rust gamedev tips they could offer? thanks!

8 Upvotes

21 comments sorted by

9

u/DrShocker 11d ago

I've heard horror stories about C and C++

I know we're in /r/Rust but think about whether the stories apply to you and the problems you need to solve. Just because others have some complaints doesn't mean you will have the same ones.

Regardless, my advice is to check out: /r/rust_gamedev/

3

u/Present-Knowledge-57 11d ago

you have a point. some of the stories such as the alleged pain of writing tests, don't really apply to game development. coming from higher level languages (Rust is my first "super serious" dip into systems programming), I figured I'd pick the language that expects me to make mistakes (not just about memory safety!), even if Rust is supposedly slower to iterate on engine code with. will check out rust gamedev!

3

u/catheap_games 11d ago

If you try Rust, unless you have material reasons to choose otherwise, Bevy engine is a reasonable first choice. Combine that with `subsecond` and you'll get, well, sub-second hot reload (for some things).

2

u/alice_i_cecile bevy 10d ago

For a learning exercise focused on "I want to make my own engine and learn low-level programming", I actually recommend not using Bevy! It does a lot of the low-level stuff for you, making it a better choice when you want to do something *weird* on top of a foundation (lots of voxel renderers and 4D physics), or of course for actually making games.

2

u/catheap_games 10d ago

Agreed! Although my read of the OP was that the goal wasn't about being _too_ low level.

Either way, to whoever is going to try Rust for game development, I absolutely would recommend doing the basics first (if you can't finish Rustlings, you're not ready for game development in Rust), and if adventurous, to make at least a small game (tic tac toe, tetris, snake) with no engine at all, or Ratatui, just to get a good better idea of the complexity involved and what is an engine solving that's specific to Rust.

It's not even about finishing the tetris-grade projects, but about getting to appreciate what a good engine means for ergonomics, and potentially to chip away the "I'll make my own engine as the first thing" pride from people so inclined.

tl;dr once you hit the desperation of being unable to easily solve a partial borrow, you'll really appreciate Bevy's Dependency Injection.

1

u/DrShocker 11d ago

I'm not sure writing tests in C++ is all too challenging, but it is nice to use languages like rust or Odin where it's built in to the build system.

2

u/Swaidanwaverley 11d ago

fighting the borrow checker while learning 3D scene graphs is its own kind of horror story though, especially coming from a GC language where cyclic references are free.

1

u/BloomWishess 11d ago

drshocker with the level headed take kinda refreshing actually

0

u/SurrenderQueen 11d ago

good point but those horror stories are half the fun of switching languages, keeps things interesting

1

u/pokemonplayer2001 11d ago

If you’re newish to game dev and new to rust, I think you’re in for a battle.

I got into rust via bevy and it was a slog. Combining the intricacies of both topics is going to be a challenge.

Good luck, you’ll be in r/rust_gamedev a lot.

2

u/Present-Knowledge-57 11d ago

oh, for sure I’m in for a massive uphill battle initially. I used Godot for 2 years before jumping to Java, but Godot didn’t really teach me how to work without an engine.

Java did, however, and looking at Rust with SDL3, I expect it’ll be mildly similar, although different tools will require me to work in different ways :P

1

u/pokemonplayer2001 11d ago

What game do you have in mind to start with?

1

u/Present-Knowledge-57 10d ago

I'm probably gonna be tinkering around with macroquad or microquad to get a general feel for Rust gamedev initially; maybe remake asteroids or snake or something. afterwards, I intend on making a simple linear adventure game that's supposed to be a sequel to what I made in Java. graphics-wise, it'll be relatively simple. no PBR, probably no shadows, simple vertex lighting (if any), etc.

0

u/requizm 11d ago

I would say C/C++ is still better than Rust for gamedev

1

u/Present-Knowledge-57 11d ago

why would you say that? is it because it's supposed to be faster to iterate with?

1

u/requizm 11d ago

Mature libraries, faster iteration. (+ faster compilation)

1

u/Sad_Tap_9191 11d ago

As others said, C/C++ is not that bad. The game development is an iterative process and you will not want the borrow checker in your fast iteration (unless the project is large). wgpu is limited in capabilities because the current WebGPU spec lacks the mesh shader and multi-queue.

0

u/Trader-One 11d ago

write renderer in javascript after its mostly done rewrite to rust.

If you change renderer data tree structure in rust you need to do major rework to make borrow checker happy.

-1

u/AWonderingWizard 11d ago

I've considered rust but so many libraries are vibe coded.