Skip to content

A base for a standalone ImGui application.

Notifications You must be signed in to change notification settings

HNT8/Standalone-ImGui

Repository files navigation

Standalone ImGui Application Base v2

A base for a standalone ImGui application. The only file you have to modify is UI.cpp

Window Class Structure

  • windowHandle (HWND)
  • windowClass (WNDCLASSEXA)
  • windowSize (WindowSize)
    • Width (int)
    • Height (int)
  • windowCoordinates (WindowCoordinates)
    • Left (int)
    • Right (int)
    • Bottom (int)
    • Top (int)
    • Center (Vector)
      • X (int)
      • Y (int)
  • directX (PDIRECT3D9)
  • directXDevice (LPDIRECT3DDEVICE9)
  • directXParameters (D3DPRESENT_PARAMETERS)
  • imGuiContext (ImGuiContext*)
  • imGuiIO (ImGuiIO*)

Modifying UI

All ImGui features can be used in the RunUI() function located in UI.cpp

void RunUI(Window* window) {
	ImGui::SetNextWindowPos({ 0, 0 });
	ImGui::SetNextWindowSize({ (float)window->windowSize.Width, (float)window->windowSize.Height });
	ImGui::Begin(Configuration::Initial::WindowTitle, &window->exiting, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoMove);

	ImGui::Text("Window Width: %d", window->windowSize.Width);
	ImGui::Text("Window Height: %d", window->windowSize.Height);
	ImGui::Separator();
	ImGui::Text("Window Left: %d", window->windowCoordinates.Left);
	ImGui::Text("Window Right: %d", window->windowCoordinates.Right);
	ImGui::Text("Window Top: %d", window->windowCoordinates.Top);
	ImGui::Text("Window Bottom: %d", window->windowCoordinates.Bottom);
	ImGui::Text("Window Center: (%d,%d)", window->windowCoordinates.Center.x, window->windowCoordinates.Center.y);

	if (ImGui::Button("test"))
		MessageBoxA(0, "test", "test", 0);

	ImGui::End();
}

Runs the specified code before creating the Window, DirectX Device, & ImGui

You can run anything you need to in the Starting() function located in UI.cpp

void Starting() {
   // Do something here before initializing anything.
}

Runs the specified code after destroying the Window, DirectX Device, & ImGui

You can run anything you need to in the Exiting() function located in UI.cpp

void Exiting() {
   // Do something here after right before exiting.
}

Runs the specified code before the while loop, after creating the Window, DirectX Device, & ImGui

You can run anything you need to in the PostInitialization(Window* window) function located in UI.cpp

void PostInitialization(Window* window)() {
   // Do something here before initializing anything.
}

Runs the specified code after the while loop, before destroying the Window, DirectX Device, & ImGui

You can run anything you need to in the PreDeinitialization(Window* window) function located in UI.cpp

void PreDeinitialization(Window* window) {
   // Do something here after right before exiting.
}