DEV Community

UJWAL KC
UJWAL KC

Posted on

Setting Up the project for Game Engine (Rust Game Engine Dev #1)

So, Let's get started.

I assume that you know the concepts of rust before diving in if not you can read my previous blog here

I assume that you have already install rust and cargo on your computer. Go to your folder where you want to create the project. Then open your terminal and type

cargo new yourprojectname
Enter fullscreen mode Exit fullscreen mode

This will create a project files with some default files i assume you know about it. Then you have to add dependencies on Cargo.toml file. You can do it in two ways.

Manually adding dependencies on Cargo.toml file
This way you name the dependencies followed by their version using double quote. Don't forget to save file after adding the dependencies.

[dependencies]
env_logger = "0.11.7"
gl = "0.14.0"
glam = "0.30.0"
pollster = "0.4.0"
sdl2 = "0.37.0"

Enter fullscreen mode Exit fullscreen mode

Or you can use cargo add command. This adds the latest version automatically

cargo add env_logger 
cargo add gl 
cargo add glam 
cargo add pollster 
cargo add sdl2 
Enter fullscreen mode Exit fullscreen mode

NOTE If you want install same version as me paste the following code

cargo add env_logger --version "0.11.7"
cargo add gl --version "0.14.0"
cargo add glam --version "0.30.0"
cargo add pollster --version "0.4.0"
cargo add sdl2 --version "0.37.0"
Enter fullscreen mode Exit fullscreen mode

After that run cargo build in your terminal this will download all the dependencies that you added to your Cargo.toml file. It will create Cargo.lock file and target folder i again assume you know about this as well.

Now lets talk about what those dependencies do

env_logger : This is used for logging meaning it notes what is happening while running our code so debugging is easy.

gl : gl provides OpenGL API so you can easily use it on your project. Basically we use gl for rendering shaders or display 2D or 3D graphics on screen.

glam : glam is a maths library for graphic. Don't be scared you just need to have basic knowledge about vectors, co-ordinates and matrices. glam is used for transforming our objects or movement of objects.

pollster : This used to avoid the problems when we load assets our code might load all the resources at same time which might cause our program to crash to avoid such situation we use pollster.

sdl2 : This is popular window creation library it handles user input, manages audio.

This is it for this post. In next post we will talk about how to initialize the project into git and commit our project to github.

Hot sauce if you're wrong - web dev trivia for staff engineers

Hot sauce if you're wrong ยท web dev trivia for staff engineers (Chris vs Jeremy, Leet Heat S1.E4)

  • Shipping Fast: Test your knowledge of deployment strategies and techniques
  • Authentication: Prove you know your OAuth from your JWT
  • CSS: Demonstrate your styling expertise under pressure
  • Acronyms: Decode the alphabet soup of web development
  • Accessibility: Show your commitment to building for everyone

Contestants must answer rapid-fire questions across the full stack of modern web development. Get it right, earn points. Get it wrong? The spice level goes up!

Watch Video ๐ŸŒถ๏ธ๐Ÿ”ฅ

Top comments (0)

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

๐Ÿ‘‹ Kindness is contagious

DEV is better (more customized, reading settings like dark mode etc) when you're signed in!

Okay