Skip to content

Commit

Permalink
remove last ImGui_State
Browse files Browse the repository at this point in the history
  • Loading branch information
scribam committed Sep 5, 2024
1 parent 9eaf0a4 commit 93722ea
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion vita3k/gui/include/gui/imgui_impl_sdl.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForMetal(SDL_Window* window);
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForSDLRenderer(SDL_Window* window, SDL_Renderer* renderer);
IMGUI_IMPL_API bool ImGui_ImplSDL2_InitForOther(SDL_Window* window);
IMGUI_IMPL_API void ImGui_ImplSDL2_Shutdown();
IMGUI_IMPL_API void ImGui_ImplSDL2_NewFrame(ImGui_State *state);
IMGUI_IMPL_API void ImGui_ImplSDL2_NewFrame();
IMGUI_IMPL_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event);

// Gamepad selection automatically starts in AutoFirst mode, picking first available SDL_Gamepad. You may override this.
Expand Down
2 changes: 1 addition & 1 deletion vita3k/gui/src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ void init(GuiState &gui, EmuEnvState &emuenv) {
}

void draw_begin(GuiState &gui, EmuEnvState &emuenv) {
ImGui_ImplSDL2_NewFrame(gui.imgui_state.get());
ImGui_ImplSDL2_NewFrame();
ImGui::NewFrame();
emuenv.renderer_focused = !ImGui::GetIO().WantCaptureMouse;

Expand Down
20 changes: 6 additions & 14 deletions vita3k/gui/src/imgui_impl_sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ static void ImGui_ImplSDL2_UpdateGamepads()
ImGui_ImplSDL2_UpdateGamepadAnalog(bd, io, ImGuiKey_GamepadRStickDown, SDL_CONTROLLER_AXIS_RIGHTY, +thumb_dead_zone, +32767);
}

void ImGui_ImplSDL2_NewFrame(ImGui_State *state)
void ImGui_ImplSDL2_NewFrame()
{
ImGui_ImplSDL2_Data* bd = ImGui_ImplSDL2_GetBackendData();
IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplSDL2_Init()?");
Expand All @@ -690,20 +690,12 @@ void ImGui_ImplSDL2_NewFrame(ImGui_State *state)
SDL_GetWindowSize(bd->Window, &w, &h);
if (SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_MINIMIZED)
w = h = 0;

switch (state->renderer->current_backend) {
case renderer::Backend::OpenGL:
SDL_GL_GetDrawableSize(bd->Window, &display_w, &display_h);
break;

case renderer::Backend::Vulkan:
if (bd->Renderer != nullptr)
SDL_GetRendererOutputSize(bd->Renderer, &display_w, &display_h);
else if (SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_VULKAN)
SDL_Vulkan_GetDrawableSize(bd->Window, &display_w, &display_h);
break;

default:
LOG_ERROR("Missing ImGui init for backend {}.", static_cast<int>(state->renderer->current_backend));
}

else if (SDL_GetWindowFlags(bd->Window) & SDL_WINDOW_OPENGL)
SDL_GL_GetDrawableSize(bd->Window, &display_w, &display_h);
io.DisplaySize = ImVec2((float)w, (float)h);
if (w > 0 && h > 0)
io.DisplayFramebufferScale = ImVec2((float)display_w / w, (float)display_h / h);
Expand Down
2 changes: 1 addition & 1 deletion vita3k/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ bool install_archive_content(EmuEnvState &emuenv, GuiState *gui, const ZipPtr &z
gui::GenericDialogState status = gui::UNK_STATE;

while (handle_events(emuenv, *gui) && (status == gui::UNK_STATE)) {
ImGui_ImplSDL2_NewFrame(gui->imgui_state.get());
ImGui_ImplSDL2_NewFrame();
ImGui::NewFrame();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gui::draw_ui(*gui, emuenv);
Expand Down

0 comments on commit 93722ea

Please sign in to comment.