diff --git a/emulator/Common.cpp b/emulator/Common.cpp index 9e3e15a..86b6383 100644 --- a/emulator/Common.cpp +++ b/emulator/Common.cpp @@ -179,16 +179,6 @@ void DebugLogFormat(LPCTSTR pszFormat, ...) const TCHAR* REGISTER_NAME[] = { _T("R0"), _T("R1"), _T("R2"), _T("R3"), _T("R4"), _T("R5"), _T("SP"), _T("PC") }; -void GetFontWidthAndHeight(HDC hdc, int* pWidth, int* pHeight) -{ - TEXTMETRIC tm; - GetTextMetrics(hdc, &tm); - if (pWidth != NULL) - *pWidth = tm.tmAveCharWidth; - if (pHeight != NULL) - *pHeight = tm.tmHeight; -} - // Print octal 16-bit value to buffer // buffer size at least 7 characters void PrintOctalValue(TCHAR* buffer, WORD value) @@ -226,41 +216,22 @@ void PrintBinaryValue(TCHAR* buffer, WORD value) } // Parse octal value from text -BOOL ParseOctalValue(LPCTSTR text, WORD* pValue) +bool ParseOctalValue(const char* text, uint16_t* pValue) { WORD value = 0; - TCHAR* pChar = (TCHAR*) text; + char* pChar = (char*) text; for (int p = 0; ; p++) { - if (p > 6) return FALSE; - TCHAR ch = *pChar; pChar++; + if (p > 6) return false; + char ch = *pChar; pChar++; if (ch == 0) break; - if (ch < _T('0') || ch > _T('7')) return FALSE; + if (ch < '0' || ch > '7') return false; value = (value << 3); - TCHAR digit = ch - _T('0'); + char digit = ch - '0'; value += digit; } *pValue = value; - return TRUE; -} - -void DrawOctalValue(HDC hdc, int x, int y, WORD value) -{ - TCHAR buffer[7]; - PrintOctalValue(buffer, value); - TextOut(hdc, x, y, buffer, (int)_tcsnlen(buffer, 6)); -} -void DrawHexValue(HDC hdc, int x, int y, WORD value) -{ - TCHAR buffer[7]; - PrintHexValue(buffer, value); - TextOut(hdc, x, y, buffer, (int)_tcsnlen(buffer, 6)); -} -void DrawBinaryValue(HDC hdc, int x, int y, WORD value) -{ - TCHAR buffer[17]; - PrintBinaryValue(buffer, value); - TextOut(hdc, x, y, buffer, 16); + return true; } void CopyTextToClipboard(LPCTSTR text) diff --git a/emulator/Common.h b/emulator/Common.h index 0578dee..c47a0c0 100644 --- a/emulator/Common.h +++ b/emulator/Common.h @@ -71,19 +71,14 @@ const int UKNC_SCREEN_WIDTH = 640; const int UKNC_SCREEN_HEIGHT = 288; -void GetFontWidthAndHeight(HDC hdc, int* pWidth, int* pHeight); void PrintOctalValue(TCHAR* buffer, WORD value); void PrintHexValue(TCHAR* buffer, WORD value); void PrintBinaryValue(TCHAR* buffer, WORD value); -BOOL ParseOctalValue(LPCTSTR text, WORD* pValue); -void DrawOctalValue(HDC hdc, int x, int y, WORD value); -void DrawHexValue(HDC hdc, int x, int y, WORD value); -void DrawBinaryValue(HDC hdc, int x, int y, WORD value); +bool ParseOctalValue(const char* text, uint16_t* pValue); void CopyTextToClipboard(LPCTSTR text); TCHAR Translate_KOI8R(BYTE ch); -void DrawCharKOI8R(HDC hdc, int x, int y, BYTE ch); BOOL ShowSaveDialog(HWND hwndOwner, LPCTSTR strTitle, LPCTSTR strFilter, LPCTSTR strDefExt, TCHAR* bufFileName); BOOL ShowOpenDialog(HWND hwndOwner, LPCTSTR strTitle, LPCTSTR strFilter, TCHAR* bufFileName); diff --git a/emulator/ConsoleView.cpp b/emulator/ConsoleView.cpp index ce3db26..6406cd5 100644 --- a/emulator/ConsoleView.cpp +++ b/emulator/ConsoleView.cpp @@ -48,13 +48,6 @@ void ConsoleView_ImGuiWidget() if (ImGui::BeginChild("ScrollingRegion", ImVec2(0, -footer_height_to_reserve), ImGuiChildFlags_None, ImGuiWindowFlags_HorizontalScrollbar | ImGuiWindowFlags_AlwaysVerticalScrollbar)) { - if (ImGui::BeginPopupContextWindow()) - { - if (ImGui::Selectable("Clear")) - ConsoleView_ClearConsole(); - ImGui::EndPopup(); - } - //TODO: ImGuiListClipper for (std::string item : m_ConsoleItems) { @@ -66,6 +59,9 @@ void ConsoleView_ImGuiWidget() } } + if (ImGui::IsWindowHovered() && ImGui::IsMouseReleased(ImGuiMouseButton_Right)) + ImGui::OpenPopup("Console_context"); + // Keep up at the bottom of the scroll region if we were already at the bottom at the beginning of the frame. // Using a scrollbar or mouse-wheel will take away from the bottom edge. if (m_ScrollToBottom || (/*AutoScroll &&*/ ImGui::GetScrollY() >= ImGui::GetScrollMaxY())) @@ -91,6 +87,13 @@ void ConsoleView_ImGuiWidget() } ImGui::EndDisabled(); + if (ImGui::BeginPopupContextItem("Console_context")) + { + if (ImGui::Selectable("Clear")) + ConsoleView_ClearConsole(); + ImGui::EndPopup(); + } + ImGui::End(); } @@ -155,6 +158,13 @@ void ConsoleView_StepOver() // Execute command ConsoleView_DoConsoleCommand(); } +void ConsoleView_AddBreakpoint(uint16_t address) +{ + // Put command to console prompt + sprintf(m_ConsoleInputBuf, "b%06ho", address); + // Execute command + ConsoleView_DoConsoleCommand(); +} void ConsoleView_DeleteBreakpoint(uint16_t address) { // Put command to console prompt diff --git a/emulator/DebugViews.cpp b/emulator/DebugViews.cpp index 9e69e76..ee09b27 100644 --- a/emulator/DebugViews.cpp +++ b/emulator/DebugViews.cpp @@ -118,6 +118,7 @@ void StackView_ImGuiWidget() // Breakpoints uint16_t m_BreakpointsContextAddress = 0177777; +char m_BreakpointBuf[7] = { 0 }; void Breakpoints_ImGuiWidget() { @@ -129,6 +130,7 @@ void Breakpoints_ImGuiWidget() uint16_t addressBreakpointClick = 0177777; const uint16_t* pbps = g_okDebugCpuPpu ? Emulator_GetCPUBreakpointList() : Emulator_GetPPUBreakpointList(); + int bpcount = 0; if (pbps != nullptr && *pbps != 0177777) { while (*pbps != 0177777) @@ -143,10 +145,10 @@ void Breakpoints_ImGuiWidget() if (isDeleteHovered) { ImGui::TextColored(ImVec4(1.0f, 0.0f, 0.0f, 1.0f), ICON_FA_MINUS_CIRCLE); - ImGui::SameLine(0.0f, 0.0f); + ImGui::SameLine(); } - ImGui::SetCursorPosX(24.0f); + ImGui::SetCursorPosX(26.0f); uint16_t address = *pbps; ImGui::Text("%06ho", address); @@ -158,6 +160,7 @@ void Breakpoints_ImGuiWidget() if (isDeleteHovered && ImGui::IsMouseReleased(ImGuiMouseButton_Left)) // Click on Delete sign addressBreakpointClick = address; + bpcount++; pbps++; } } @@ -166,7 +169,7 @@ void Breakpoints_ImGuiWidget() ConsoleView_DeleteBreakpoint(addressBreakpointClick); bool linesHovered = ImGui::IsMouseHoveringRect(linesMin, linesMax); - if (!linesHovered && ImGui::IsMouseReleased(ImGuiMouseButton_Right)) // Context menu in empty area + if (ImGui::IsWindowHovered() && !linesHovered && ImGui::IsMouseReleased(ImGuiMouseButton_Right)) // Context menu in empty area { m_BreakpointsContextAddress = 0177777; ImGui::OpenPopup("Breakpoints_context"); @@ -185,6 +188,33 @@ void Breakpoints_ImGuiWidget() ImGui::EndPopup(); } + if (bpcount < MAX_BREAKPOINTCOUNT) + { + ImGui::TextDisabled(ICON_FA_PLUS_CIRCLE); + ImGui::SameLine(); + ImGui::SetCursorPosX(26.0f); + ImGuiInputTextFlags input_text_flags = ImGuiInputTextFlags_EnterReturnsTrue | ImGuiInputTextFlags_EscapeClearsAll; + uint16_t address; + bool addressParsed = false; + if (*m_BreakpointBuf != 0) + addressParsed = ParseOctalValue(m_BreakpointBuf, &address); + ImGui::PushItemWidth(ImGui::CalcTextSize("000000 ").x); + if (ImGui::InputText("###BreakpointNew", m_BreakpointBuf, IM_ARRAYSIZE(m_BreakpointBuf), input_text_flags)) + { + if (addressParsed) + { + ConsoleView_AddBreakpoint(address); + *m_BreakpointBuf = 0; + } + } + if (*m_BreakpointBuf != 0 && !addressParsed) + { + ImGui::SameLine(); + ImGui::Text(ICON_FA_EXCLAMATION_TRIANGLE); + } + ImGui::PopItemWidth(); + } + ImGui::End(); } diff --git a/emulator/DisasmView.cpp b/emulator/DisasmView.cpp index 3e1bc76..2b3a957 100644 --- a/emulator/DisasmView.cpp +++ b/emulator/DisasmView.cpp @@ -106,7 +106,7 @@ void Disasm_DrawForRunningEmulator() void DisasmView_DrawJump(ImDrawList* draw_list, ImVec2 lineMin, int delta, float cyLine) { - ImU32 col = ImGui::ColorConvertFloat4ToU32(ImVec4(0.67f, 0.67f, 0.67f, 0.67f)); + ImU32 col = ImGui::ColorConvertFloat4ToU32(ImVec4(0.5f, 0.7f, 1.0f, 0.67f)); int dist = abs(delta); if (dist < 2) dist = 2; @@ -115,14 +115,25 @@ void DisasmView_DrawJump(ImDrawList* draw_list, ImVec2 lineMin, int delta, float float yTo = lineMin.y + delta * cyLine; ImVec2 p1(lineMin.x + cyLine * 0.2f, lineMin.y + cyLine / 2.0f); // point from - ImVec2 p2(lineMin.x + dist * cyLine * 0.4f, p1.y); - ImVec2 p3(lineMin.x + dist * cyLine * 1.2f, yTo); + ImVec2 p2(lineMin.x + dist * cyLine * 0.32f, p1.y); + ImVec2 p3(lineMin.x + dist * cyLine * 0.9f, yTo); ImVec2 p4(lineMin.x, yTo - cyLine * 0.1f); // point to - ImVec2 p5(lineMin.x + cyLine * 0.6f, yTo - cyLine * 0.15f); // arrow - ImVec2 p6(lineMin.x + cyLine * 0.6f, yTo + cyLine * 0.15f); // arrow draw_list->AddBezierCubic(p1, p2, p3, p4, col, 1.0); - draw_list->AddLine(p4, p5, col); - draw_list->AddLine(p4, p6, col); + + // Arrow sides + ImVec2 p5(lineMin.x + cyLine * 0.8f, yTo); // upper side + ImVec2 p6(lineMin.x + cyLine * 0.8f, yTo); // down side + if (delta > 0) // jump down + { + p5.y -= cyLine * 0.27f; + p6.y += cyLine * 0.01f; + } + else // jump up + { + p5.y -= cyLine * 0.10f; + p6.y += cyLine * 0.15f; + } + draw_list->AddTriangleFilled(p4, p5, p6, col); } // В режиме останова делаем подробный дизасм diff --git a/emulator/Emulator.cpp b/emulator/Emulator.cpp index a048ded..fad6f12 100644 --- a/emulator/Emulator.cpp +++ b/emulator/Emulator.cpp @@ -71,22 +71,22 @@ const BYTE m_arrDigitKeyScans[] = const uint32_t ScreenView_StandardGRBColors[16 * 8] = { - 0xFF000000, 0xFF000080, 0xFF800000, 0xFF800080, 0xFF008000, 0xFf008080, 0xFF808000, 0xFF808080, - 0xFF000000, 0xFF0000FF, 0xFFFF0000, 0xFFFF00FF, 0xFF00FF00, 0xFF00FFFF, 0xFFFFFF00, 0xFFFFFFFF, - 0xFF000000, 0xFF000060, 0xFF800000, 0xFF800060, 0xFF008000, 0xFF008060, 0xFF808000, 0xFF808060, - 0xFF000000, 0xFF0000DF, 0xFFFF0000, 0xFFFF00DF, 0xFF00FF00, 0xFF00FFDF, 0xFFFFFF00, 0xFFFFFFDF, - 0xFF000000, 0xFF000080, 0xFF600000, 0xFF600080, 0xFF008000, 0xFF008080, 0xFF608000, 0xFF608080, - 0xFF000000, 0xFF0000FF, 0xFFDF0000, 0xFFDF00FF, 0xFF00FF00, 0xFF00FFFF, 0xFFDFFF00, 0xFFDFFFFF, - 0xFF000000, 0xFF000060, 0xFF600000, 0xFF600060, 0xFF008000, 0xFF008060, 0xFF608000, 0xFF608060, - 0xFF000000, 0xFF0000DF, 0xFFDF0000, 0xFFDF00DF, 0xFF00FF00, 0xFF00FFDF, 0xFFDFFF00, 0xFFDFFFDF, - 0xFF000000, 0xFF000080, 0xFF800000, 0xFF800080, 0xFF006000, 0xFF006080, 0xFF806000, 0xFF806080, - 0xFF000000, 0xFF0000FF, 0xFFFF0000, 0xFFFF00FF, 0xFF00DF00, 0xFF00DFFF, 0xFFFFDF00, 0xFFFFDFFF, - 0xFF000000, 0xFF000060, 0xFF800000, 0xFF800060, 0xFF006000, 0xFF006060, 0xFF806000, 0xFF806060, - 0xFF000000, 0xFF0000DF, 0xFFFF0000, 0xFFFF00DF, 0xFF00DF00, 0xFF00DFDF, 0xFFFFDF00, 0xFFFFDFDF, - 0xFF000000, 0xFF000080, 0xFF600000, 0xFF600080, 0xFF006000, 0xFF006080, 0xFF606000, 0xFF606080, - 0xFF000000, 0xFF0000FF, 0xFFDF0000, 0xFFDF00FF, 0xFF00DF00, 0xFF00DFFF, 0xFFDFDF00, 0xFFDFDFFF, - 0xFF000000, 0xFF000060, 0xFF600000, 0xFF600060, 0xFF006000, 0xFF006060, 0xFF606000, 0xFF606060, - 0xFF000000, 0xFF0000DF, 0xFFDF0000, 0xFFDF00DF, 0xFF00DF00, 0xFF00DFDF, 0xFFDFDF00, 0xFFDFDFDF, + 0xFF000000, 0xFF800000, 0xFF008000, 0xFF808000, 0xFF000080, 0xFF800080, 0xFF008080, 0xFF808080, + 0xFF000000, 0xFFFF0000, 0xFF00FF00, 0xFFFFFF00, 0xFF0000FF, 0xFFFF00FF, 0xFF00FFFF, 0xFFFFFFFF, + 0xFF000000, 0xFF600000, 0xFF008000, 0xFF608000, 0xFF000080, 0xFF600080, 0xFF008080, 0xFF608080, + 0xFF000000, 0xFFDF0000, 0xFF00FF00, 0xFFDFFF00, 0xFF0000FF, 0xFFDF00FF, 0xFF00FFFF, 0xFFDFFFFF, + 0xFF000000, 0xFF800000, 0xFF006000, 0xFF806000, 0xFF000080, 0xFF800080, 0xFF006080, 0xFF806080, + 0xFF000000, 0xFFFF0000, 0xFF00DF00, 0xFFFFDF00, 0xFF0000FF, 0xFFFF00FF, 0xFF00DFFF, 0xFFFFDFFF, + 0xFF000000, 0xFF600000, 0xFF006000, 0xFF606000, 0xFF000080, 0xFF600080, 0xFF006080, 0xFF606080, + 0xFF000000, 0xFFDF0000, 0xFF00DF00, 0xFFDFDF00, 0xFF0000FF, 0xFFDF00FF, 0xFF00DFFF, 0xFFDFDFFF, + 0xFF000000, 0xFF800000, 0xFF008000, 0xFF808000, 0xFF000060, 0xFF800060, 0xFF008060, 0xFF808060, + 0xFF000000, 0xFFFF0000, 0xFF00FF00, 0xFFFFFF00, 0xFF0000DF, 0xFFFF00DF, 0xFF00FFDF, 0xFFFFFFDF, + 0xFF000000, 0xFF600000, 0xFF008000, 0xFF608000, 0xFF000060, 0xFF600060, 0xFF008060, 0xFF608060, + 0xFF000000, 0xFFDF0000, 0xFF00FF00, 0xFFDFFF00, 0xFF0000DF, 0xFFDF00DF, 0xFF00FFDF, 0xFFDFFFDF, + 0xFF000000, 0xFF800000, 0xFF006000, 0xFF806000, 0xFF000060, 0xFF800060, 0xFF006060, 0xFF806060, + 0xFF000000, 0xFFFF0000, 0xFF00DF00, 0xFFFFDF00, 0xFF0000DF, 0xFFFF00DF, 0xFF00DFDF, 0xFFFFDFDF, + 0xFF000000, 0xFF600000, 0xFF006000, 0xFF606000, 0xFF000060, 0xFF600060, 0xFF006060, 0xFF606060, + 0xFF000000, 0xFFDF0000, 0xFF00DF00, 0xFFDFDF00, 0xFF0000DF, 0xFFDF00DF, 0xFF00DFDF, 0xFFDFDFDF, }; @@ -720,12 +720,6 @@ bool Emulator_SystemFrame() double dFramesPerSecond = m_nFrameCount * 1000.0 / nTicksElapsed; double dSpeed = dFramesPerSecond / 25.0 * 100; g_dFramesPercent = dSpeed; - //TCHAR buffer[16]; - //_sntprintf(buffer, sizeof(buffer) / sizeof(TCHAR) - 1, _T("%03.f%%"), dSpeed); - //MainWindow_SetStatusbarText(StatusbarPartFPS, buffer); - - //bool floppyEngine = g_pBoard->IsFloppyEngineOn(); - //MainWindow_SetStatusbarText(StatusbarPartFloppyEngine, floppyEngine ? _T("Motor") : nullptr); m_nFrameCount = 0; m_dwTickCount = dwCurrentTicks; @@ -744,7 +738,6 @@ bool Emulator_SystemFrame() TCHAR buffer[20]; _sntprintf(buffer, sizeof(buffer) / sizeof(TCHAR) - 1, _T("Uptime: %02d:%02d:%02d"), hours, minutes, seconds); - //MainWindow_SetStatusbarText(StatusbarPartUptime, buffer); } // Update "Sound" indicator every 5 frames @@ -752,7 +745,6 @@ bool Emulator_SystemFrame() if (m_nUptimeFrameCount % 5 == 0) { bool soundOn = m_nEmulatorSoundChanges > 0; - //MainWindow_SetStatusbarText(StatusbarPartSound, soundOn ? _T("Sound") : nullptr); m_nEmulatorSoundChanges = 0; } diff --git a/emulator/Main.h b/emulator/Main.h index a216de3..a00bc7e 100644 --- a/emulator/Main.h +++ b/emulator/Main.h @@ -179,6 +179,7 @@ void ConsoleView_ImGuiWidget(); void ConsoleView_Print(const char* message); void ConsoleView_StepInto(); void ConsoleView_StepOver(); +void ConsoleView_AddBreakpoint(uint16_t address); void ConsoleView_DeleteBreakpoint(uint16_t address); void ConsoleView_DeleteAllBreakpoints(); diff --git a/emulator/MainWindow.cpp b/emulator/MainWindow.cpp index b8d8987..7026641 100644 --- a/emulator/MainWindow.cpp +++ b/emulator/MainWindow.cpp @@ -108,24 +108,47 @@ void ImGuiMainMenu() { if (!g_okEmulatorRunning) { - if (ImGui::MenuItem("Run")) + if (ImGui::MenuItem(ICON_FA_PLAY " Run")) Emulator_Start(); } else { - if (ImGui::MenuItem("Stop")) + if (ImGui::MenuItem(ICON_FA_PAUSE " Stop")) Emulator_Stop(); } - if (ImGui::MenuItem("Reset")) + if (ImGui::MenuItem(ICON_FA_REDO " Reset")) Emulator_Reset(); - bool autostart = Settings_GetAutostart(); if (ImGui::MenuItem("Autostart", nullptr, &autostart)) { Settings_SetAutostart(!Settings_GetAutostart()); } + ImGui::Separator(); + + WORD speed = Settings_GetRealSpeed(); + bool checked25 = speed == 0x7ffe; + ImGui::BeginDisabled(checked25); + if (ImGui::MenuItem("Speed 25%", nullptr, &checked25)) MainWindow_DoEmulatorSpeed(0x7ffe); + ImGui::EndDisabled(); + bool checked50 = speed == 0x7fff; + ImGui::BeginDisabled(checked50); + if (ImGui::MenuItem("Speed 50%", nullptr, &checked50)) MainWindow_DoEmulatorSpeed(0x7fff); + ImGui::EndDisabled(); + bool checked100 = speed == 1; + ImGui::BeginDisabled(checked100); + if (ImGui::MenuItem("Speed 100%", nullptr, &checked100)) MainWindow_DoEmulatorSpeed(1); + ImGui::EndDisabled(); + bool checked200 = speed == 200; + ImGui::BeginDisabled(checked200); + if (ImGui::MenuItem("Speed 200%", nullptr, &checked200)) MainWindow_DoEmulatorSpeed(2); + ImGui::EndDisabled(); + bool checkedMax = speed == 0; + ImGui::BeginDisabled(checkedMax); + if (ImGui::MenuItem("Speed MAX", nullptr, &checkedMax)) MainWindow_DoEmulatorSpeed(0); + ImGui::EndDisabled(); + ImGui::EndMenu(); } if (ImGui::BeginMenu("Debug")) diff --git a/emulator/ScreenView.cpp b/emulator/ScreenView.cpp index 97173a0..b0582bf 100644 --- a/emulator/ScreenView.cpp +++ b/emulator/ScreenView.cpp @@ -202,5 +202,11 @@ void ScreenView_ScanKeyboard() } } +// External key event - e.g. from KeyboardView +void ScreenView_KeyEvent(BYTE keyscan, BOOL pressed) +{ + ScreenView_PutKeyEventToQueue(MAKEWORD(keyscan, pressed ? 128 : 0)); +} + ////////////////////////////////////////////////////////////////////// diff --git a/emulator/main.cpp b/emulator/main.cpp index 0d08f96..0515d98 100644 --- a/emulator/main.cpp +++ b/emulator/main.cpp @@ -74,11 +74,6 @@ static void Hook_Renderer_SwapBuffers(ImGuiViewport* viewport, void*) } -void ScreenView_KeyEvent(BYTE keyscan, BOOL pressed) -{ - //TODO -} - void ImGuiFrame() { ImGui::NewFrame(); @@ -149,7 +144,7 @@ int main(int, char**) Emulator_SetSoundAY(Settings_GetSoundAY() != 0); Emulator_SetSoundCovox(Settings_GetSoundCovox() != 0); - ScreenView_Init(); + ScreenView_Init(); // Creates m_bits ConsoleView_Init(); //TODO: Restore main window settings @@ -212,7 +207,9 @@ int main(int, char**) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); - glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, UKNC_SCREEN_WIDTH, UKNC_SCREEN_HEIGHT, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, m_bits); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, UKNC_SCREEN_WIDTH, UKNC_SCREEN_HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_bits); + // Unbind texture + glBindTexture(GL_TEXTURE_2D, 0); g_ScreenTextureID = (void*)(intptr_t) screen_texture; @@ -290,13 +287,12 @@ int main(int, char**) Emulator_Stop(); } + //TODO: Move to ScreenView IM_ASSERT(m_bits != nullptr); Emulator_PrepareScreenRGB32(m_bits, ScreenView_StandardGRBColors); glBindTexture(GL_TEXTURE_2D, screen_texture); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, UKNC_SCREEN_WIDTH, UKNC_SCREEN_HEIGHT, GL_BGRA_EXT, GL_UNSIGNED_BYTE, m_bits); - // Unbind texture - glBindTexture(GL_TEXTURE_2D, 0); + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, UKNC_SCREEN_WIDTH, UKNC_SCREEN_HEIGHT, GL_RGBA, GL_UNSIGNED_BYTE, m_bits); } // Start the Dear ImGui frame @@ -362,6 +358,8 @@ int main(int, char**) Settings_Done(); ScreenView_Done(); + glDeleteTextures(1, &screen_texture); + ImGui_ImplOpenGL3_Shutdown(); ImGui_ImplWin32_Shutdown(); ImGui::DestroyContext();