| 3555 | } |
| 3556 | |
| 3557 | static void NewFrameSanityChecks() |
| 3558 | { |
| 3559 | ImGuiContext& g = *GImGui; |
| 3560 | |
| 3561 | // Check user data |
| 3562 | // (We pass an error message in the assert expression to make it visible to programmers who are not using a debugger, as most assert handlers display their argument) |
| 3563 | IM_ASSERT(g.Initialized); |
| 3564 | IM_ASSERT((g.IO.DeltaTime > 0.0f || g.FrameCount == 0) && "Need a positive DeltaTime!"); |
| 3565 | IM_ASSERT((g.FrameCount == 0 || g.FrameCountEnded == g.FrameCount) && "Forgot to call Render() or EndFrame() at the end of the previous frame?"); |
| 3566 | IM_ASSERT(g.IO.DisplaySize.x >= 0.0f && g.IO.DisplaySize.y >= 0.0f && "Invalid DisplaySize value!"); |
| 3567 | IM_ASSERT(g.IO.Fonts->Fonts.Size > 0 && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?"); |
| 3568 | IM_ASSERT(g.IO.Fonts->Fonts[0]->IsLoaded() && "Font Atlas not built. Did you call io.Fonts->GetTexDataAsRGBA32() / GetTexDataAsAlpha8() ?"); |
| 3569 | IM_ASSERT(g.Style.CurveTessellationTol > 0.0f && "Invalid style setting!"); |
| 3570 | IM_ASSERT(g.Style.CircleSegmentMaxError > 0.0f && "Invalid style setting!"); |
| 3571 | IM_ASSERT(g.Style.Alpha >= 0.0f && g.Style.Alpha <= 1.0f && "Invalid style setting. Alpha cannot be negative (allows us to avoid a few clamps in color computations)!"); |
| 3572 | IM_ASSERT(g.Style.WindowMinSize.x >= 1.0f && g.Style.WindowMinSize.y >= 1.0f && "Invalid style setting."); |
| 3573 | IM_ASSERT(g.Style.WindowMenuButtonPosition == ImGuiDir_None || g.Style.WindowMenuButtonPosition == ImGuiDir_Left || g.Style.WindowMenuButtonPosition == ImGuiDir_Right); |
| 3574 | for (int n = 0; n < ImGuiKey_COUNT; n++) |
| 3575 | IM_ASSERT(g.IO.KeyMap[n] >= -1 && g.IO.KeyMap[n] < IM_ARRAYSIZE(g.IO.KeysDown) && "io.KeyMap[] contains an out of bound value (need to be 0..512, or -1 for unmapped key)"); |
| 3576 | |
| 3577 | // Perform simple check: required key mapping (we intentionally do NOT check all keys to not pressure user into setting up everything, but Space is required and was only recently added in 1.60 WIP) |
| 3578 | if (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) |
| 3579 | IM_ASSERT(g.IO.KeyMap[ImGuiKey_Space] != -1 && "ImGuiKey_Space is not mapped, required for keyboard navigation."); |
| 3580 | |
| 3581 | // Perform simple check: the beta io.ConfigWindowsResizeFromEdges option requires back-end to honor mouse cursor changes and set the ImGuiBackendFlags_HasMouseCursors flag accordingly. |
| 3582 | if (g.IO.ConfigWindowsResizeFromEdges && !(g.IO.BackendFlags & ImGuiBackendFlags_HasMouseCursors)) |
| 3583 | g.IO.ConfigWindowsResizeFromEdges = false; |
| 3584 | } |
| 3585 | |
| 3586 | void ImGui::NewFrame() |
| 3587 | { |