How Godot works under the hood?

When comes to compiling the instructions are very detailed how to use scons, to build editor , templates.

But how about under hood operation?

I’m currently taking course on Zenva to learn more about C++ Learn Object-Oriented C++ by Building a Game, currently in half of it - Inheritance .

So I thought, this sounds like much of the concept from Godot. Why not have look, but I’m a bit overwhelmed with amount of files and not sure if start in core, main, scene or somewhere else to get practice.

Would appreciate any tips where to start as beginner, or if this even make sense to looking in existing code.

1 Like

It doesn’t for a beginner. I mean, you always can if you’re up for an adventure, but don’t expect to easily understand it. It’s not just the language, you need to have a decent level of knowledge about general computing and computer graphics concepts and other stuff that typically go into an engine. Those things are not related to any specific language.

In any case, better to gain some more experience with C++ fundamentals first by making your own programs and looking at (or compiling/altering) smaller projects on github, within your area of interest.

5 Likes

The documentation has an engine architecture section.

4 Likes

Thank you.

I keep that in mind.

Based of diagram, I would bet to start with Main to discover what structs, pointers, methods,

The Main component is responsible for initializing and managing the engine lifecycle, including startup, shutdown, and the main loop.

I didn’t found structor and destructor next to each other like in DX12 sample from Microsoft.

		Sample3DSceneRenderer(const std::shared_ptr<DX::DeviceResources>& deviceResources);
		~Sample3DSceneRenderer();

instead in main.cpp is lengthly cleanup method.

void Main::cleanup(bool p_force)

Godot is a C++ program like any other. It always runs from the first line in int main(int argc, char **argv). Since it can be conditionally compiled for multiple platforms, there is a platform specific main() for each supported platform.

Linux main is in/platform/linuxbsd/godot_linuxbsd.cpp. For windows it’s in /platform/windows/godot_windows.cpp and so on.

Those do some platform specific setup, then call Main::setup() and Main::start(), and finally call platform specific run() that enters engine’s main loop.

As for Main constructors/destructors, there aren’t any because it’s just a static class. All functions there are static so Main basically serves as a mere namespace.

2 Likes

Thank you for taking time to explaining it.

For those calls Main::setup() and Main::start() I couldn’t locate them.

I see the godot_linuxbsd.cpp included platform/linuxbsd/os_linuxbsd.h. with this:

They are right there in main(), at lines 111 and 121.

After those two, it calls OS_LinuxBSD::run() which runs an endless while loop that is engine’s main loop. In simplified terms, an Iteration of this loop runs once per frame until you quit the program.

2 Likes

indeed.

I saw the TEST so ignored the below

Screenshot 2026-11-01 at 15.10.44

It’s a macro defined in main.h

1 Like

Far ahead from game building along the course, but it’s nice to see how much works someone putted down to make this engine happens.

At a high level, Godot is C++ built around a few core ideas that make it easier to follow than it first looks:

- The SceneTree drives the main loop, and every node is a C++ object. GDScript, C# and GDExtension are scripting layers on top of that object system, so a call you make in script usually ends up in C++.

- Most subsystems are ‘servers’ with a small API: RenderingServer, PhysicsServer and AudioServer. That keeps the editor, the game logic and the platform drivers decoupled from each other.

- Rendering goes through a driver abstraction (Vulkan in Godot 4). Each frame the rendering server turns the scene into draw calls, rather than nodes drawing themselves directly.

- The editor itself is a Godot project built with the same engine, which is why so much of it can be extended with plugins.

If you want to read the source, the folders are a good map: core/ has the object and Variant system, scene/ has the node tree, and servers/ has the low-level subsystems. main/main.cpp is a good starting point, since that is where setup and the main loop live.

1 Like

main.cpp

Why need for display_server , rendering_device, rendering_server, rendering_server_default ?

In static members only two pointers are used