void ImGui_Win32_Application_Entry_Point () {
  ImGui_ImplWin32_EnableDpiAwareness();
  f32 main_scale = ImGui_ImplWin32_GetDpiScaleForMonitor(::MonitorFromPoint(POINT{ 0, 0 }, MONITOR_DEFAULTTOPRIMARY));
  
  bool success = false;

  success = os_create_window("Main Window", nullptr, true, true, false, ImGui_WndProc);
  if (!success) {
    Assert(false);
    ExitProcess(1);
  }
  
  get_main_window_pointer()->tray_icon_menu = CreatePopupMenu();
  AppendMenuW(get_main_window_pointer()->tray_icon_menu, MF_STRING, ICON_CONTEXT_MENU_ITEM_ID, L"Exit");
  
  HWND hwnd = get_main_window().window;
  
  success = Win32_Load_Main_Window_Icon("tmp.ico");
  if (!success) { log_warning("Failed to load tmp.ico"); }
  success = Win32_Load_Main_Window_Icon_Minimized("tmp_min.ico");
  if (!success) { log_warning("Failed to load tmp_min.ico"); }

  //  :Win32_Initialize_Extended
  Win32_Set_Main_Icon();
  Win32_Set_Tray_Icon("Musa's File Explorer");
  Win32_Hide_Tray_Icon();
  
  if (!CreateDeviceD3D(hwnd)) {
    CleanupDeviceD3D();
    return;
  }
  
  // Set dark titlebar
  s64 dark_mode = 1;
  DWORD USE_IMMERSIVE_DARK_MODE = 20;
  ::DwmSetWindowAttribute(hwnd, USE_IMMERSIVE_DARK_MODE, &dark_mode, sizeof(s64));
  // A hacky workaround to display the dark title bar properly. Nothing else we've tried worked
  ::ShowWindow(hwnd, SW_HIDE);
  ::ShowWindow(hwnd, SW_SHOW);

  // Setup Dear ImGui context
  IMGUI_CHECKVERSION();
  log("ImGui Version %s \n", ImGui::GetVersion());
  
  imgui_context = ImGui::CreateContext();
  
  ImGuiIO& io = ImGui::GetIO(); (void)io;
  // io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;     // Enable Keyboard Controls
  // io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad;      // Enable Gamepad Controls
  io.ConfigFlags |= ImGuiConfigFlags_DockingEnable;         // Enable Docking
  io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable;       // Enable Multi-Viewport / Platform Windows
  
  // io.ConfigViewportsNoAutoMerge = true; // io.ConfigViewportsNoTaskBarIcon = true; // io.ConfigDockingAlwaysTabBar = true;
  // io.ConfigDockingTransparentPayload = true;
  
  // Setup Dear ImGui style
  // ImGui::StyleColorsDark();
  Set_Custom_Style();
  
  // Setup scaling
  ImGuiStyle& style = ImGui::GetStyle();
  style.ScaleAllSizes(main_scale);        // Bake a fixed style scale. (until we have a solution for dynamic style scaling, changing this requires resetting Style + calling this again)
  style.FontScaleDpi = main_scale;        // Set initial font scale. (using io.ConfigDpiScaleFonts=true makes this unnecessary. We leave both here for documentation purpose)
  io.ConfigDpiScaleFonts = true;          // [Experimental] Automatically overwrite style.FontScaleDpi in Begin() when Monitor DPI changes. This will scale fonts but _NOT_ scale sizes/padding for now.
  io.ConfigDpiScaleViewports = true;      // [Experimental] Scale Dear ImGui and Platform Windows when Monitor DPI changes.

  // When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones.
  if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) {
    style.WindowRounding = 0.0f;
    style.Colors[ImGuiCol_WindowBg].w = 1.0f;
  }
  
  // Setup Platform/Renderer backends
  ImGui_ImplWin32_Init(hwnd);
  ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
  
  style.FontSizeBase = 24.0f;
  //io.Fonts->AddFontDefault();

  string font_file_name = "RobotoMono-Regular.ttf";
  
  { push_allocator_label("ImGui Default Font");
    imgui_default_font.sizes.allocator = default_allocator();
    imgui_default_font.font_name = font_file_name;
  
    for (s64 i = 0; i < ArrayCount(imgui_font_sizes); i += 1) {
      f32 font_size = imgui_font_sizes[i];
      ImFont* new_font = io.Fonts->AddFontFromFileTTF((char*)font_file_name.data, font_size);
      if (new_font) {
        ImGui_Font_Size_Pair pair = {font_size, new_font};
        array_add(imgui_default_font.sizes, pair);
      }
    }
  }
  
  bool show_demo_window = true;
  bool show_another_window = false;
  ImVec4 clear_color = ImVec4(0.45f, 0.55f, 0.60f, 1.00f);

  // Main loop
  bool done = false;
  
  // Cache HDC before initializing Icons but after setting up D3D11:
  get_main_window_pointer()->hdc = GetDC(hwnd);
  
  push_allocator(temp()); // default allocator for temporary UI stuff. 
  
  while (!done) {
    // Poll and handle messages (inputs, window resize, etc.)
    // See the WndProc() function below for our to dispatch events to the Win32 backend.
    MSG msg;
    while (::PeekMessage(&msg, nullptr, 0U, 0U, PM_REMOVE)) {
      ::TranslateMessage(&msg);
      ::DispatchMessage(&msg);
      if (msg.message == WM_QUIT) {
        done = true;
      }
    }

    // Handle window being minimized or screen locked
    if ((g_SwapChainOccluded && g_pSwapChain->Present(0, DXGI_PRESENT_TEST) == DXGI_STATUS_OCCLUDED) || ::IsIconic(hwnd)) {
        ::Sleep(10);
        continue;
    }
    g_SwapChainOccluded = false;

    // Handle window resize (we don't resize directly in the WM_SIZE handler)
    if (g_ResizeWidth != 0 && g_ResizeHeight != 0) {
      CleanupRenderTarget();
      g_pSwapChain->ResizeBuffers(0, g_ResizeWidth, g_ResizeHeight, DXGI_FORMAT_UNKNOWN, 0);
      g_ResizeWidth = g_ResizeHeight = 0;
      CreateRenderTarget();
    }

    // Start the Dear ImGui frame
    ImGui_ImplDX11_NewFrame();
    ImGui_ImplWin32_NewFrame();
    ImGui::NewFrame();
    
    ImGui_Push_Default_Font();
    // Simple dockspace:
    ImGui::DockSpaceOverViewport();

    ImGui_Debug_Panel();
  
    ImGui_Pop_Default_Font();

    // Rendering
    ImGui::Render();
    const f32 clear_color_with_alpha[4] = { clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w };
    g_pd3dDeviceContext->OMSetRenderTargets(1, &g_mainRenderTargetView, nullptr);
    g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha);
    ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());

    // Update and Render additional Platform Windows
    if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) {
      ImGui::UpdatePlatformWindows();
      ImGui::RenderPlatformWindowsDefault();
    }
    
    // Present
    HRESULT hr = g_pSwapChain->Present(1, 0);   // Present with vsync
    // HRESULT hr = g_pSwapChain->Present(0, 0); // Present without vsync
    g_SwapChainOccluded = (hr == DXGI_STATUS_OCCLUDED);
    
    temp_reset_keeping_memory(); // reset_temporary_storage
  } // while (!done)
  
  // Cleanupre
  ImGui_ImplDX11_Shutdown();
  ImGui_ImplWin32_Shutdown();
  ImGui::DestroyContext();

  CleanupDeviceD3D();
  ::DestroyWindow(hwnd);
  
  Win32_Hide_Tray_Icon();
}
