Skip to content

Conversation

@jurassicLizard
Copy link

@jurassicLizard jurassicLizard commented Jan 15, 2026

Note : to test this please configure in Debug mode before building with -A Win32 -DRTS_BUILD_OPTION_DEBUG=ON -DRTS_BUILD_OPTION_IMGUI=On

all the code is gated behind a RTS_IMGUI_ENABLED perprocessor define for debugging purposes

  • What it does : Integrates the Dear Imgui framework and loads a console and demo window overlay
    in debug mode

  • What is missing

    • Some useful command or Ideas what it should look like : this PR will just focus on build and runtime integration via ImGui Demo
    • Currently it is permanently enabled when the game is builtwith the imgui option on Gated behind RTS_BUILD_OPTION_IMGUI
    • Code cleanup and SuperHackers Comments etc... done
    • Backporting to Generals done
Screenshot (9) Screenshot (11)

@jurassicLizard jurassicLizard changed the title feat(gameclient) Introduce imgui framework and console feat(gameclient) Introduce imgui framework Jan 16, 2026
@jurassicLizard jurassicLizard marked this pull request as ready for review January 16, 2026 15:01
@greptile-apps
Copy link

greptile-apps bot commented Jan 16, 2026

Greptile Summary

Integrates Dear ImGui framework for debug overlays in both Generals and Zero Hour, gated behind RTS_BUILD_OPTION_IMGUI and restricted to Debug builds. The implementation includes a custom DX8 backend since ImGui doesn't officially support DirectX 8.

Key changes:

  • Custom DX8 renderer backend (imgui_impl_dx8.cpp) based on community implementation
  • CMake integration that fetches ImGui from GitHub and enforces Debug-only builds
  • Proper integration into game loop: input handling in WndProc, frame lifecycle in GameClient, rendering in DX8Wrapper
  • Device reset handling with proper invalidation/recreation of ImGui resources
  • Comprehensive comments documenting the integration workflow

Previous issues addressed:

  • Redundant ImGui::Render() calls have been removed
  • Typo "moore" has been fixed
  • Null pointer checks added for GetDepthStencilSurface() return values
  • Error handling improved for buffer lock operations

Minor style observations:

  • Some uses of NULL instead of nullptr remain in imgui_impl_dx8.cpp (lines 72, 184, 311, 340) per custom rule c69cf1a9

Confidence Score: 4/5

  • Safe to merge with minor style inconsistencies
  • The integration is well-architected with proper lifecycle management and error handling. Previous critical issues (redundant render calls, nullptr derefs) have been fixed. Only minor style issues remain with NULL vs nullptr usage.
  • Core/Libraries/Source/ImGui/dx8_backend/imgui_impl_dx8.cpp has style inconsistencies with NULL vs nullptr

Important Files Changed

Filename Overview
Core/Libraries/Source/ImGui/dx8_backend/imgui_impl_dx8.cpp Custom DX8 backend implementation for ImGui with proper error handling for depth stencil operations
Core/Libraries/Source/ImGui/CMakeLists.txt CMake configuration that fetches ImGui and configures the build with debug mode requirement
Generals/Code/GameEngine/Source/GameClient/GameClient.cpp Integration of ImGui frame lifecycle in game client update loop with proper render calls before early returns
Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp DX8 wrapper handles ImGui context initialization, device reset, and render data output

Sequence Diagram

sequenceDiagram
    participant User
    participant WndProc
    participant GameClient
    participant DX8Wrapper
    participant ImGui
    participant DX8Device

    Note over User,DX8Device: Initialization (Create_Device)
    DX8Wrapper->>ImGui: CreateContext()
    DX8Wrapper->>ImGui: ImGui_ImplWin32_Init(hwnd)
    DX8Wrapper->>ImGui: ImGui_ImplDX8_Init(device)
    ImGui->>DX8Device: AddRef()

    Note over User,DX8Device: Frame Loop
    User->>WndProc: Input Events
    WndProc->>ImGui: ImGui_ImplWin32_WndProcHandler()
    
    GameClient->>ImGui: ImGui_ImplDX8_NewFrame()
    GameClient->>ImGui: ImGui_ImplWin32_NewFrame()
    GameClient->>ImGui: ImGui::NewFrame()
    GameClient->>ImGui: ImGui::ShowDemoWindow()
    GameClient->>ImGui: ImGui::Render()
    
    GameClient->>DX8Wrapper: TheDisplay->DRAW()
    DX8Wrapper->>DX8Device: BeginScene()
    Note over DX8Wrapper: Render game content
    DX8Wrapper->>ImGui: ImGui::GetDrawData()
    DX8Wrapper->>ImGui: ImGui_ImplDX8_RenderDrawData()
    ImGui->>DX8Device: SetRenderState/DrawIndexedPrimitive
    DX8Wrapper->>DX8Device: EndScene()

    Note over User,DX8Device: Device Reset
    DX8Wrapper->>ImGui: ImGui_ImplDX8_InvalidateDeviceObjects()
    DX8Wrapper->>DX8Device: Reset()
    DX8Wrapper->>ImGui: ImGui_ImplDX8_CreateDeviceObjects()

    Note over User,DX8Device: Shutdown
    DX8Wrapper->>ImGui: ImGui_ImplDX8_Shutdown()
    DX8Wrapper->>ImGui: ImGui_ImplWin32_Shutdown()
    DX8Wrapper->>ImGui: DestroyContext()
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

14 files reviewed, 4 comments

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link

greptile-apps bot commented Jan 16, 2026

Greptile found no issues!

From now on, if a review finishes and we haven't found any issues, we will not post anything, but you can confirm that we reviewed your changes in the status check section.

This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR".

@jurassicLizard jurassicLizard force-pushed the feature/imgui_console_integration branch from ab35d8a to 742f8be Compare January 16, 2026 16:09
@jurassicLizard
Copy link
Author

@greptileai

@jurassicLizard
Copy link
Author

relates to : #387 and #2084 (comment)

@jurassicLizard jurassicLizard force-pushed the feature/imgui_console_integration branch from de59853 to d7e3765 Compare January 18, 2026 08:11
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

14 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@jurassicLizard jurassicLizard changed the title feat(gameclient) Introduce imgui framework feat(gameclient): Introduce imgui framework Jan 19, 2026
  when opening worldbuilder or guiedit ImGui has no
  frames to render and thus attemtimg to call RenderDrawData
  crashes in those applications as soon as they start
  this change fixes that behaviour by only
  rendering when we have stuff to render
@jurassicLizard jurassicLizard force-pushed the feature/imgui_console_integration branch from d7e3765 to 4e08d7e Compare January 19, 2026 09:51
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

14 files reviewed, 4 comments

Edit Code Review Agent Settings | Greptile

jurassicLizard and others added 3 commits January 19, 2026 10:57
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@jurassicLizard
Copy link
Author

@greptileai

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

14 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

@xezon xezon added Enhancement Is new feature or request Major Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour Debug Is mostly debug functionality labels Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Debug Is mostly debug functionality Enhancement Is new feature or request Gen Relates to Generals Major Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants