Skip to content

Commit 1237bae

Browse files
SoapyManclaude
andcommitted
- docs: update sys overview and architecture for ImGui host in imgui_backend
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 1829107 commit 1237bae

2 files changed

Lines changed: 32 additions & 21 deletions

File tree

‎docs/architecture.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ Public interfaces are declared in `public/` and implemented in `core/` or `share
8787
| `shared/audio/` | Audio system on OpenAL, sound emitters/scripts/mixer; `source/` holds WAV/OGG sources |
8888
| `shared/physics/` | EqPhysics engine on top of Bullet collision — see [physics_overview.md](physics_overview.md) |
8989
| `shared/equi/` | EqUI interface library: manager, controls, scheme |
90-
| `shared/imgui_backend/` | ImGui host and material-system renderer backend |
90+
| `shared/imgui_backend/` | ImGui host (`g_imGuiHost`), SDL platform backend and material-system renderer backend |
9191
| `shared/scripting/` | ESL — Lua binding library |
9292
| `shared/movie/` | WebM movie player: AV1 video (dav1d), Vorbis audio, YUV to RGBA conversion on GPU (`MovieYUV` shader) |
9393
| `shared/network/` | UDP networking |
9494
| `shared/input/` | Input command binder |
95-
| `shared/sys/` | Application host: main loop, window, states, console, joystick, config loader; `sys/scripting/` exposes engine subsystems to ESL, `sys/imgui/` is the ImGui platform backend |
95+
| `shared/sys/` | Application host: main loop, window, states, console, joystick, config loader; `sys/scripting/` exposes engine subsystems to ESL |
9696
| `shared/components/`, `shared/entity/` | Component system and data tables (no engine project; compiled by consumers) |
9797
| `tools/` | Content tools (see below); `localization_tool/` is a separate C# project, `imp-exp blender/` is a Blender add-on |
9898
| `samples/` | Sample applications, each with its own workspace `premake5.lua` |
@@ -208,7 +208,7 @@ All are static libraries using `public` and `shared` include paths.
208208
| `studioLib` | `studio/**` | studioFileLib |
209209
| `animatingLib` | `animating/**` | studioLib |
210210
| `equiLib` | `equi/**` | fontLib (imgui) |
211-
| `imguiBackendLib` | `imgui_backend/**` | (imgui) |
211+
| `imguiBackendLib` | `imgui_backend/**` | (SDL2, imgui) |
212212
| `networkLib` | `network/**` except `NETThread.cpp` | (zlib) |
213213
| `soundSystemLib` | `audio/**` | (minivorbis, openal-soft, imgui) |
214214
| `physicsLib` | `physics/**` | (bullet2) |

‎docs/sys_application_overview.md‎

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ input routing, configs and screenshots. An application links `sysLib` (premake p
1111
| `sys_window.cpp/.h` | Window creation, SDL init, game loop (`sysHostInit`, `sysHostGameLoop`, `sysHostTerminate`) |
1212
| `sys_host.cpp/.h` | `g_pHost` (`CGameHost`) — systems, frame, video modes, cursor, input events |
1313
| `sys_state.cpp/.h` | `CAppStateBase`, `eqAppStateMng` — app states |
14-
| `sys_in_console.cpp/.h` | `g_consoleInput` (`CEqConsoleInput`) — developer console, log, ImGui frame |
14+
| `sys_in_console.cpp/.h` | `g_consoleInput` (`CEqConsoleInput`) — developer console, log |
1515
| `sys_in_joystick.cpp/.h` | `CEqGameControllerSDL` — game controllers |
1616
| `cfgloader.cpp/.h` | `WriteCfgFile`, `writecfg` |
1717
| `sys_version.cpp/.h` | `ENGINE_NAME`, `ENGINE_VERSION`, `COMPILE_*`, `GetEngineBuildNumber()` |
18-
| `imgui/imgui_impl_sys.*` | ImGui platform backend for SDL |
1918
| `scripting/` | Engine Lua state and bindings ([scripting_esl_overview.md](scripting_esl_overview.md)) |
2019

2120
`sysLib` also compiles `shared/input` ([input_overview.md](input_overview.md)) and uses
22-
`renderUtilLib`, `equiLib`, `movieLib`, `scriptLib`, SDL2 and the ImGui backend.
21+
`renderUtilLib`, `equiLib`, `movieLib`, `scriptLib`, SDL2 and `imguiBackendLib` (`g_imGuiHost`,
22+
`shared/imgui_backend`, which also contains the ImGui platform backend for SDL).
2323

2424
## Start-up and shutdown
2525

@@ -39,7 +39,8 @@ WinMain / main
3939
│ │ ├─ window (vid_mode, vid_fullscreen, vid_screen), command line (+cmd value)
4040
│ │ ├─ g_matSystem->Init() RHI on the SDL window
4141
│ │ ├─ g_fontCache, g_localizer (+GAME_VERSION, BUILD_NUMBER tokens),
42-
│ │ │ debugoverlay, equi::Manager, g_inputCommandBinder, g_consoleInput (ImGui)
42+
│ │ │ debugoverlay, g_imGuiHost (ImGui on the SDL window), equi::Manager,
43+
│ │ │ g_inputCommandBinder, g_consoleInput
4344
│ │ └─ REGISTER_INTERNAL_SHADERS() material shaders compiled into the application
4445
│ └─ CEqGameControllerSDL::Init()
4546
├─ sysHostGameLoop()
@@ -130,15 +131,17 @@ frame the loop sleeps `sys_sleep` ms (default 1).
130131
1. Measures time. With `sys_maxfps` set, the frame is skipped until enough time passed; the frame
131132
time is clamped to 0.001–0.1 s.
132133
2. `g_onBeginFrame`, controller button repeats, cursor state.
133-
3. `BeginScene`: `g_matSystem->BeginFrame`, `r_wireframe` / `r_overdraw`, console / ImGui frame
134-
start.
134+
3. `BeginScene`: `g_matSystem->BeginFrame`, console frame start, ImGui frame start
135+
(`g_imGuiHost->BeginFrame`, debug menus while the console is open), `r_wireframe` /
136+
`r_overdraw`.
135137
4. `eqAppStateMng::UpdateStates(dt × state timescale × sys_timescale)` — the current state
136138
renders and queues its command buffers.
137139
5. EqUI render, full-screen edge AA, `g_matSystem->SubmitQueuedCommandsAwaitable()`.
138140
6. Debug overlay with engine statistics (FPS, draw / dispatch counts, GPU and system memory),
139-
`r_showFPS`, `r_showFPSGraph`, input debug drawing.
140-
7. `EndScene`: screenshot (without console / ImGui), console and ImGui drawing,
141-
`g_matSystem->EndFrame()`.
141+
`r_showFPS`, `r_showFPSGraph`. Screenshot (without console / ImGui), then one render pass with
142+
the debug overlay, input debug drawing, console (`g_consoleInput->EndFrame`) and ImGui
143+
(`g_imGuiHost->EndFrame`).
144+
7. `EndScene`: `g_matSystem->EndFrame()`.
142145
8. Pending fullscreen toggle, `g_onEndFrame`.
143146

144147
`GetFrameTime()` returns the current frame time; `GetWindowSize()`, `GetDefaultFont()`,
@@ -165,29 +168,37 @@ dispatched by `CGameHost`:
165168

166169
| Event | Order |
167170
|---|---|
168-
| Keyboard | console → EqUI → state `HandleKeyPress` |
169-
| Mouse buttons | console / ImGui → EqUI → (touch emulation with `m_clicks_to_touch`) → state `HandleMouseClick` |
171+
| Keyboard | console toggle key → ImGui → console → EqUI → state `HandleKeyPress` |
172+
| Mouse buttons | ImGui → console → EqUI → (touch emulation with `m_clicks_to_touch`) → state `HandleMouseClick` |
170173
| Mouse movement | console / ImGui position → EqUI → `g_inputCommandBinder->OnVectorEvent(MOU_MOVE)` → state `HandleMouseMove` |
171-
| Mouse wheel | console → binder (`MOU_MOVE`) → state `HandleMouseWheel` |
174+
| Mouse wheel | ImGui → console → binder (`MOU_MOVE`) → state `HandleMouseWheel` |
172175
| Controller buttons / axes | binder → state `HandleKeyPress` / `HandleJoyAxis` |
173176
| Touch | binder touch zones |
174-
| Text input | console |
177+
| Text input | ImGui → console |
175178

176179
Keyboard keys and mouse buttons reach command bindings only if the state forwards them to
177180
`g_inputCommandBinder->OnPressEvent` (see [input_overview.md](input_overview.md)). Input is ignored
178181
for 0.25 s after the window regains focus.
179182

183+
ImGui (`g_imGuiHost->Input*`) receives keys, mouse buttons, wheel and text first. While an ImGui
184+
item is hovered, active or focused, or ImGui wants the mouse / keyboard
185+
(`g_imGuiHost->IsImGuiItemsInFocus()`), the event goes no further; key releases still reach the
186+
console so its modifier state does not stick.
187+
180188
## Developer console — `g_consoleInput`
181189

182-
- Opened by the `+con_toggle` command (bind it to a key, e.g. `bind GRAVE +con_toggle` in
183-
`cfg/config_default.cfg`), or `con_show`, `con_show_full`, `con_hide`; `clear`, `help`.
190+
- Opened by the key bound to `toggleconsole` (`bind GRAVE toggleconsole` in
191+
`cfg/config_default.cfg`). `CGameHost::Key_Event` checks this key before any other input
192+
handling, so it works while ImGui has focus; with the console open, Shift + the key toggles the
193+
log view. Also `con_toggle` / `+con_toggle`, `con_show`, `con_show_full`, `con_hide`; `clear`,
194+
`help`.
184195
- Executes console commands (see [framework_core.md](framework_core.md)) with autocompletion,
185196
variants, history and a log view. With the Lua state initialized, input that fails as a command
186197
is executed as Lua (`SetAlternateHandler`, see [scripting_esl_overview.md](scripting_esl_overview.md)).
187198
- ConVars: `con_size`, `con_suggest`, `con_minicon`, `con_minicon_time`.
188-
- The console owns the ImGui frame (`g_imGuiHost`, `shared/imgui_backend`): ImGui windows registered
189-
with `g_imGuiHost->AddDebugHandler` are always drawn, and the debug menu bar with
190-
`AddDebugMenu(path, handler)` entries is shown while the console is open.
199+
- ImGui is run by the host (`g_imGuiHost`, `shared/imgui_backend`), not the console: ImGui
200+
windows registered with `g_imGuiHost->AddDebugHandler` are always drawn, and the debug menu bar
201+
with `AddDebugMenu(path, handler)` entries is shown while the console is open.
191202
- `CEqConsoleInput::SpewInit` captures engine log output for the console log from the start.
192203

193204
## Configuration files

0 commit comments

Comments
 (0)