r/gameenginedevs • • 2d ago

how can I read a Game Engine source code?

Idk how can i explain it well but a little context, I am studying Cpp for build my game engine, I want to create a game and it's a good opportunity to take this challenge. Recently I know CryEngine was buy for Amazon and it change to O3DE, I read before in this sunreddit is a good practice take a Game Engine Open Source for understand how it works but unfortunately Idk what is you main function, what kind of project it have, I love read code from others people and it's interesting how their solve that kind of weird problem with this amazing solution. anybody could you help me?

Sorry for my english dude

0 Upvotes

23 comments sorted by

9

u/Left-Locksmith 2d ago edited 2d ago

Okay, whatever looks like one single "game engine" is actually, like everything else in software, a sequence of solutions to individually small problems stacked one atop the other.

Graphics programming: This is where your program reads numbers representing 3D data, and tells the pixels on your monitor what colours they should emit. Much of this work is done on the GPU these days.

Audio programming: This is where your program reads audio data (time series of numbers centered around 0 representing a sound wave), modifies it, pushes it to your sound card which pushes it to your speaker.

Physics: This is where you define what happens when two pieces of geometry intersect, or constrain each other by distance or angle along some axis. Also where position updates based on velocity, and velocity updates based on external forces, are performed.

Input handling: This is where key presses and analog device movements are combined into commands understood by your engine's scripting system.

Scripting: The interface through which a game dev using your engine writes "business logic." E.g., Collision logic saying when ball hits bat play "smash" sound effect and add XYZ velocity to the velocity of the ball.

Networking: I mean you can guess, right?

The "Engine:" the architectural glue allowing all the individual bits to interact without exploding.

My recommendation is to learn a framework like SDL, make a small 2D game with inputs, simple physics, audio, and then return to this question. It'll give you a small taste of everything an engine does, and you can decide afterwards what interests you the most.

Most engine code just isn't going to make sense to you until you understand the problems they're trying to solve.

0

u/MammothWing1128 2d ago

I am doing it, I made simple games as tetris using Raylib and learn networking following Build your Own Redis for understand how it works. I gonna make some simple games for my personal portfolio and then, I try to made my own simple game. thanks dude!

3

u/ChameleonCoder117 2d ago

I don't really understand what the post is supposed to mean but if you want to read the code of game engines, here's a list:

Unreal code is available, but their lawyers WILL hawk your ass down if you try to modify and redistribute it

Open 3d Engine is open source

Godot is open source

Source 2013 build is open source

Id tech 1-4 is open source

Bevy is open source

Raylib is open source

Cocos is open source

1

u/MammothWing1128 2d ago

Perhaps, I dont expain well, in this explication i gonna use Bevy, I read before for understand how it works but idk what is the main function and all those process, I can use AI for help me to understand this code but personal reason I dont want to use it, for this reason I'm asking for

12

u/tastygames_official 2d ago

CryEngine was licensed to Amazon but then Amazon heavily modified it and combined it with their engine Lumberyard which eventually turned into the O3DE project. CryEngine is closed-source, but O3DE is open-source: https://o3de.org/ https://github.com/o3de/o3de

so you can read the entire source.

The other person already mentioned Unreal, which is open-source but not free. You also have FOSS (free and open source software) godot game engine: https://godotengine.org/ https://github.com/godotengine/godot

11

u/khedoros 2d ago

The other person already mentioned Unreal, which is open-source but not free.

It's usually described as "source-available", to make that distinction.

2

u/MCWizardYT 2d ago

CryEngine is closed source

It's actually on a "source available" model like Unreal Engine. You can sign up to get access to a private GitHub repository containing the code for CryEngine 5.7

1

u/tastygames_official 2d ago

well, yeah - I guess to me closed-source means "proprietary, we don't let just anyone see it, but people can partner with us and gain access to it". That is how Unreal was at the beginning - I guess it still is? I thought it was actually publically available.

So yeah - Cry and Unreal and I feel I should mention Unigine are all closed-source but you can gain access to it by partnering with them and signing an NDA. Basically how all non-open-source software works. Windows is "source available" as you can gain access to it if you partner with them or work directly for them. So I feel personally that "source available" doesn't really mean much and I prefer "closed source".

1

u/MCWizardYT 2d ago

It's publicly available in that literally anybody can sign up to get access and there's no verification process, or ndas, or any other type of signed documentation. All you need is a GitHub account.

The only restriction is that you can't fork the code into a public repository. GitHub doesn't even let you.

8

u/Responsible-Offer724 2d ago

study the classics (much more approachable, and the foundations upon which all 3D engines are built upon)

https://github.com/id-Software

I know you said you don't want to use AI at all, but use it as a compliment to explain topics you are having trouble wrapping your head around. You don't need to and should not generate a single line of code with it if you're trying to learn, but if you're trying to learn accelerating your understanding is a good idea.

1

u/cherrycode420 2d ago

Welll .... you search for an open source game engine, check the corresponding git repository, then browse the files and read the source code of whatever seems to be of interest for you.

If that's too much effort, you're probably not ready to try and create your own game engine, unless your goal is to vibecode the #8374692027 frankenstein project bundling SDL, ImGui, Assimp etc. and calling it your own. For those kinds of pseudo-engines, the only unique feature is usually what styling they applied to ImGui 🤡

If you want to create a game, create a game, not a game engine, unless you actually have technical requirements that can't be solved using existing solutions.

1

u/Responsible-Offer724 2d ago edited 2d ago

hey don't knock SDL! there is almost no point whatsoever in reinventing that wheel

0

u/MammothWing1128 2d ago

I understand you point of view but honestly I no wanna use AI in any context, for lack of experience idk how really read any game engine code.

For this reason I am asking to expert the best way to do it

1

u/Outside-Storage-1523 2d ago

I think you need to first make your own engine, hopefully a simple one, and then pick a simpler commercial or open sourced engine to read.

2

u/MammothWing1128 2d ago

I think the same, maybe look one very simple kind of 2D or something else. but honestly I appreciate it the help i received.

1

u/MCWizardYT 2d ago

It's like reading the code for any other type of project. Any good engine has documentation that will tell you where to start

0

u/Thin_Tradition8467 2d ago

1

u/Responsible-Offer724 2d ago

u know that doesn't go anywhere right?

1

u/MCWizardYT 2d ago

It does, but only after you've linked your GitHub account to the organization

They have instructions: https://github.com/EpicGames/.github/blob/main/profile/README.md

1

u/Responsible-Offer724 2d ago

ah, that is useful info

1

u/MCWizardYT 2d ago

Yeah its called a shared-source model, where people are allowed to see and even contribute to the code but they legally arent allowed to publicly dhare it anywhere

Im in two other projects like this, CryEngine and Hytale