godotengine/godot
Windows
Purpose
platform/windows/ is the Windows platform layer. It supplies an OS_Windows subclass, a Win32 DisplayServer, joypad input via XInput / DirectInput, audio via WASAPI / XAudio2, exports to .exe (with PCK bundling), code signing, and the GDK / console-friendly bits where applicable.
Layout
platform/windows/
├── godot_windows.cpp / godot_windows_console.cpp WinMain + console entry
├── os_windows.{cpp,h} OS_Windows subclass
├── display_server_windows.{cpp,h} Win32 + DwmApi window + input
├── joypad_windows.{cpp,h} XInput + DirectInput gamepads
├── crash_handler_windows.{cpp,h} MiniDumpWriteDump + StackWalk64
├── windows_terminal_logger.{cpp,h} Colored terminal logging via the modern Windows Console
├── tts_windows.{cpp,h} ISpeechSynthesizer / SAPI TTS bindings
├── gl_manager_windows_native.{cpp,h}, gl_manager_windows_angle.{cpp,h} WGL + ANGLE
├── ime/ IME composition handling
├── export/ Windows exporter (.exe, PCK embed, signing)
├── godot_res.rc, godot.natvis Windows resource file + Visual Studio debug visualizer
└── detect.pyDisplay server
DisplayServerWindows uses the standard Win32 message pump (WM_*). It handles:
- Multiple windows via
CreateWindowExperWindownode. - HiDPI awareness with per-monitor v2 scaling.
- IME via
ImmGetContext/ImmSetCompositionWindow. - Drag-and-drop via
IDropTarget. - File dialogs via the modern
IFileDialog. - Tablet input via
WM_POINTERon Windows 8+. - Status indicators (system tray) via
Shell_NotifyIcon. - Window flags: borderless, transparent, on-top, taskbar visibility.
Rendering driver hookup
- Vulkan uses
VK_KHR_win32_surface. The driver lives indrivers/vulkan/. - Direct3D 12 is the recommended modern path; the driver lives in
drivers/d3d12/and creates anIDXGISwapChain3against the HWND. - OpenGL ES 3 (compatibility renderer) — uses ANGLE (Microsoft's WebGL→D3D translator) by default for stability, with a native WGL fallback.
gl_manager_windows_angle.cppandgl_manager_windows_native.cppcover both.
The choice is driven by --rendering-driver and the project setting rendering/renderer/rendering_method.
OS_Windows specifics
- Filesystem paths are
\separated; theOS::get_user_data_dir()resolves to%APPDATA%\Godot\(or%APPDATA%\<project>\when running an exported game). - Process spawning via
CreateProcess; environment viaGetEnvironmentStrings. - Console output works whether or not the process attached a console —
GODOT_WINDOWS_TERMINAL_LOGGERplus the modernWriteConsolepath enables ANSI colors on Windows Terminal. - High-resolution timing via
QueryPerformanceCounter. - Crash handler installs a top-level exception filter that writes a minidump and prints a symbolicated stack trace.
Joypad
joypad_windows.cpp supports both XInput (Xbox controllers) and DirectInput (everything else). XInput 1.4 is preferred when available; DirectInput is the fallback for older controllers, and SDL game controller mappings are applied via gamecontrollerdb.txt.
Audio
- WASAPI (
drivers/wasapi/) — default; supports shared and exclusive modes. - XAudio2 (
drivers/xaudio2/) — fallback / GDK; better suited to consoles and certain UWP-shaped builds. - WinMIDI (
drivers/winmidi/) — MIDI input viamidiInOpen.
Code signing + export
export/export_plugin.cpp:
- Embeds the project's icon into the exported
.exevia the resource section. - Embeds the PCK either inline (appended to the binary) or as a sibling
.pckfile. - Runs
signtool.exefor Authenticode signing if a certificate / timestamping URL is provided. - Optional rcedit-based metadata patching (file description, copyright).
The console launcher (godot_windows_console.exe) is shipped alongside the GUI binary so users can toggle between hidden and visible console output without rebuilding.
Key abstractions
| Abstraction | File | Role |
|---|---|---|
OS_Windows |
platform/windows/os_windows.cpp |
OS subclass |
DisplayServerWindows |
platform/windows/display_server_windows.cpp |
Win32 backend |
JoypadWindows |
platform/windows/joypad_windows.cpp |
XInput + DirectInput |
CrashHandlerWindows |
platform/windows/crash_handler_windows.cpp |
Minidumps |
WindowsTerminalLogger |
platform/windows/windows_terminal_logger.cpp |
Colored terminal logging |
EditorExportPlatformWindows |
platform/windows/export/export_plugin.cpp |
Windows exporter |
Entry points for modification
- IME / input edge cases →
display_server_windows.cppandime/. - Export flow tweaks →
export/export_plugin.cpp. - New GPU API or context type → add a manager next to
gl_manager_windows_*.cppand wire up indisplay_server_windows.cpp::_create_rendering_device.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.