module
Docs::A_ARCHITECTURE
Overview
A. Dual-Paradigm Architecture
LibGodot for Crystal is designed around a dual-paradigm architecture that provides both rapid, hot-reloading in-editor game development and lean, standalone native executable production shipping:
- Mode A: GDExtension In-Editor / Runner Paradigm (
game.dll+crystal_bridge.dll) - Mode B: Standalone LibGodot Host Paradigm (
game.exe+libgodot.dll)
Mode A: GDExtension In-Editor Workflow
Used when creating games inside the Godot Editor 4.8+ (make editor) or running
via the Godot engine binary (make run).
In this mode:
- Godot is the parent host process (
godot.exe). - Godot discovers
addons/crystal_integration/crystal.gdextensionat startup. - The manifest directs Godot to load
bin/crystal_bridge.dll(a lightweight native C++ bridge). - During library initialization (
crystal_library_init):- Godot passes its C-API function table pointer (
GDExtensionInterfaceGetProcAddress). - The bridge initializes the Boehm Garbage Collector (
GC_init()) for Crystal. - In development mode, the bridge creates a timestamped shadow copy of
game.dll(game_loaded_<PID>_<timestamp>.dll) to prevent Windows OS file lock collisions. - The bridge dynamically loads the shadow DLL via
LoadLibraryA(ordlopenon Linux). - The bridge resolves
crystal_godot_initinsidegame.dlland hands over theBridgeAPIfunction table. - Crystal registers custom nodes, signals, exported properties, and doc comments
into Godot's
ClassDBandEditorHelpsubsystems.
- Godot passes its C-API function table pointer (
- Pressing Play (F5) or Play Scene (F6) in the Godot editor invokes the
EditorPlugin._build()hook inaddons/crystal_integration/crystal_integration.gd, automatically recompilinggame.dlland reloading without restarting Godot.
Mode B: Standalone LibGodot Host Paradigm
Used for standalone shipping builds (make game_exe), embedded deployments, or CI test runners.
In this mode:
- Crystal compiles as a standalone Windows PE executable (
bin/game.exe). - Crystal owns the
main()entry point, boots its runtime, and configures GC natively. - Godot is compiled as a shared library (
bin/libgodot.dll). - Crystal loads
libgodot.dllin-memory usingLibGodot::DynamicLoader. - Crystal invokes
libgodot_create_godot_instance(argc, argv, init_callback), passing its own command-line arguments and an initialization callback. - Godot boots in-memory and invokes Crystal's
Scene-level initialization callback, registering all nodes and scene hooks directly. - Crystal steps the main loop, controls window initialization, and manages shutdown.
Comparison Table
| Feature | Mode A (GDExtension Bridge) | Mode B (Standalone LibGodot) |
|---|---|---|
| Host Process | Godot Engine (godot.exe) |
Crystal Executable (game.exe) |
| Shared Libraries | crystal_bridge.dll, game.dll |
libgodot.dll |
| Godot Editor | Full support (Inspector, Node tree, F1 Help) | Headless or embedded window |
| Hot Reloading | Live shadow reload on F5 / F6 | Recompilation of executable required |
| GC Bootstrapping | Initialized by C++ bridge (GC_init) |
Initialized natively by Crystal CRT |
| Target Use-Case | Development, editing, prototyping | Standalone production distribution |
Defined in:
libgodot/docs.crClass Method Summary
-
.overview : String
Dummy method for documentation visibility