diff --git a/code/REDALERT/SCENARIO.CPP b/code/REDALERT/SCENARIO.CPP index 05e3442..c5d0878 100644 --- a/code/REDALERT/SCENARIO.CPP +++ b/code/REDALERT/SCENARIO.CPP @@ -1607,6 +1607,8 @@ int BGMessageBox(char const * msg, int btn1, int btn2) */ Hide_Mouse(); + Show_OldFrameBuffer(false); + PaletteClass temp; #ifdef WIN32 char *filename = "SOVPAPER.PCX"; @@ -1865,6 +1867,8 @@ int BGMessageBox(char const * msg, int btn1, int btn2) GadgetClass::Set_Color_Scheme(&ColorRemaps[PCOLOR_DIALOG_BLUE]); + Show_OldFrameBuffer(true); + return(retval); } diff --git a/code/REDALERT/WINSTUB.CPP b/code/REDALERT/WINSTUB.CPP index 70b71be..655aaa9 100644 --- a/code/REDALERT/WINSTUB.CPP +++ b/code/REDALERT/WINSTUB.CPP @@ -83,8 +83,6 @@ void (*Imgui_Dialog_Function)(void) = nullptr; bool show_oldframebuffer = true; void Show_OldFrameBuffer(bool show) { show_oldframebuffer = show; - glClearColor(0, 0, 0, 1); - glClear(GL_COLOR_BUFFER_BIT); memset(backbuffer_data, 0, ScreenWidth * ScreenHeight * 4); } @@ -174,40 +172,42 @@ void Set_DD_Palette(void* palette, bool raShift) void ImGui_NewFrame(void) { ImGuiIO& io = ImGui::GetIO(); - //glClearColor(0, 0, 0, 1); - //glClear(GL_COLOR_BUFFER_BIT); + glClearColor(0, 0, 0, 1); + glClear(GL_COLOR_BUFFER_BIT); io.DisplaySize = ImVec2(ScreenWidth, ScreenHeight); ImGui_ImplOpenGL3_NewFrame(); - ImGui::NewFrame(); + ImGui::NewFrame(show_oldframebuffer); ImGui_ImplSDL2_NewFrame(game_window); } void Device_Present(void) { - // Use imgui to render the screenbuffer. - if(show_oldframebuffer) - { - // Rasterize the palette. - for (int i = 0; i < ScreenWidth * ScreenHeight; i++) { - backbuffer_data[(i * 4) + 0] = backbuffer_palette[(backbuffer_data_raw[i] * 3) + 0]; - backbuffer_data[(i * 4) + 1] = backbuffer_palette[(backbuffer_data_raw[i] * 3) + 1]; - backbuffer_data[(i * 4) + 2] = backbuffer_palette[(backbuffer_data_raw[i] * 3) + 2]; - backbuffer_data[(i * 4) + 3] = 255; - } - glBindTexture(GL_TEXTURE_2D, backbuffer_texture); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, ScreenWidth, ScreenHeight, GL_RGBA, GL_UNSIGNED_BYTE, backbuffer_data); - bool ScreenActive; - ImGuiStyle& style = ImGui::GetStyle(); - style.FramePadding = ImVec2(0, 0); - ImGui::SetNextWindowSize(ImVec2(ScreenWidth, ScreenHeight)); - ImGui::SetNextWindowPos(ImVec2(0, 0)); - ImGui::Begin("RenderWindow", &ScreenActive, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoMouseInputs); - ImVec2 desktopSize(ScreenWidth, ScreenHeight); - ImGui::Image((ImTextureID)backbuffer_texture, desktopSize); - ImGui::End(); + // Rasterize the palette. + for (int i = 0; i < ScreenWidth * ScreenHeight; i++) { + backbuffer_data[(i * 4) + 0] = backbuffer_palette[(backbuffer_data_raw[i] * 3) + 0]; + backbuffer_data[(i * 4) + 1] = backbuffer_palette[(backbuffer_data_raw[i] * 3) + 1]; + backbuffer_data[(i * 4) + 2] = backbuffer_palette[(backbuffer_data_raw[i] * 3) + 2]; + backbuffer_data[(i * 4) + 3] = 255; } + glBindTexture(GL_TEXTURE_2D, backbuffer_texture); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, ScreenWidth, ScreenHeight, GL_RGBA, GL_UNSIGNED_BYTE, backbuffer_data); + + bool ScreenActive; + ImGuiStyle& style = ImGui::GetStyle(); + style.FramePadding = ImVec2(0, 0); + ImGui::SetNextWindowSize(ImVec2(ScreenWidth, ScreenHeight)); + ImGui::SetNextWindowPos(ImVec2(0, 0)); + ImGui::Begin("RenderWindow", &ScreenActive, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoMouseInputs); + if (show_oldframebuffer) + { + ImVec2 desktopSize(ScreenWidth, ScreenHeight); + ImGui::Image((ImTextureID)backbuffer_texture, desktopSize); + } + + ImGui::End(); + if (Imgui_Dialog_Function) { Imgui_Dialog_Function(); diff --git a/code/external/imgui/imgui.cpp b/code/external/imgui/imgui.cpp index 07a832c..5b73466 100644 --- a/code/external/imgui/imgui.cpp +++ b/code/external/imgui/imgui.cpp @@ -3734,7 +3734,7 @@ ImGuiKeyModFlags ImGui::GetMergedKeyModFlags() return key_mod_flags; } -void ImGui::NewFrame() +void ImGui::NewFrame(bool clearCmdList) { IM_ASSERT(GImGui != NULL && "No current context. Did you call ImGui::CreateContext() and ImGui::SetCurrentContext() ?"); ImGuiContext& g = *GImGui; @@ -3777,16 +3777,21 @@ void ImGui::NewFrame() if (g.IO.BackendFlags & ImGuiBackendFlags_RendererHasVtxOffset) g.DrawListSharedData.InitialFlags |= ImDrawListFlags_AllowVtxOffset; - g.BackgroundDrawList.ResetForNewFrame(); - g.BackgroundDrawList.PushTextureID(g.IO.Fonts->TexID); - g.BackgroundDrawList.PushClipRectFullScreen(); - g.ForegroundDrawList.ResetForNewFrame(); - g.ForegroundDrawList.PushTextureID(g.IO.Fonts->TexID); - g.ForegroundDrawList.PushClipRectFullScreen(); // Mark rendering data as invalid to prevent user who may have a handle on it to use it. - g.DrawData.Clear(); + if (clearCmdList) { + g.BackgroundDrawList.ResetForNewFrame(); + g.BackgroundDrawList.PushClipRectFullScreen(); + + g.ForegroundDrawList.ResetForNewFrame(); + g.ForegroundDrawList.PushClipRectFullScreen(); + + g.DrawData.Clear(); + } + + g.BackgroundDrawList.PushTextureID(g.IO.Fonts->TexID); + g.ForegroundDrawList.PushTextureID(g.IO.Fonts->TexID); // Drag and drop keep the source ID alive so even if the source disappear our state is consistent if (g.DragDropActive && g.DragDropPayload.SourceId == g.ActiveId) diff --git a/code/external/imgui/imgui.h b/code/external/imgui/imgui.h index 7906ae0..457aa26 100644 --- a/code/external/imgui/imgui.h +++ b/code/external/imgui/imgui.h @@ -246,7 +246,9 @@ namespace ImGui // Main IMGUI_API ImGuiIO& GetIO(); // access the IO structure (mouse/keyboard/gamepad inputs, time, various configuration options/flags) IMGUI_API ImGuiStyle& GetStyle(); // access the Style structure (colors, sizes). Always use PushStyleCol(), PushStyleVar() to modify style mid-frame! - IMGUI_API void NewFrame(); // start a new Dear ImGui frame, you can submit any command from this point until Render()/EndFrame(). +// jmarshall - added bool clearCmdList + IMGUI_API void NewFrame(bool clearCmdList = true); // start a new Dear ImGui frame, you can submit any command from this point until Render()/EndFrame(). +// jmarshall end IMGUI_API void EndFrame(); // ends the Dear ImGui frame. automatically called by Render(). If you don't need to render data (skipping rendering) you may call EndFrame() without Render()... but you'll have wasted CPU already! If you don't need to render, better to not create any windows and not call NewFrame() at all! IMGUI_API void Render(); // ends the Dear ImGui frame, finalize the draw data. You can get call GetDrawData() to obtain it and run your rendering function (up to v1.60, this used to call io.RenderDrawListsFn(). Nowadays, we allow and prefer calling your render function yourself.) IMGUI_API ImDrawData* GetDrawData(); // valid after Render() and until the next call to NewFrame(). this is what you have to render. diff --git a/ui/sovpaper.png b/ui/sovpaper.png new file mode 100644 index 0000000..9544bde Binary files /dev/null and b/ui/sovpaper.png differ