Windows Abstraction

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By kershnerd

Can someone point me the source in GitHub of how Godot Engine handles multi-platform window abstraction or some other resource (Book, blog, GitHub, etc…) on how to do this?

I can’t find a single resource (free or paid) on how to accomplish this without using something like GLFW3.


:bust_in_silhouette: Reply From: flurick

I’m not sure what you are looking for but the there is the platform directory

:bust_in_silhouette: Reply From: BlackWave42

The abstraction is done directly into the core of the engine. In the class /core/os/os.h, there is a virtual function called “initialized”. This class is actually extended by any os_*.cpp class (in each platform directory) and an OpenGL Context is created in this specific function. This is then into that function that you should look to know how the window is created as it is required in order to create an OpenGl Context (you will probably need to get your hand on the OpenGL documentation to be able to read those parts though).

For how Godot know which os class it has to use, it is actually injected, but I don’t know when. Probably at compilation time, but it is also possible that it is at runtime, using a factory pattern (less likely as it would be less performant, and the game would be heavier, but I am not an engine dev).