diff --git a/CMakeLists.txt b/CMakeLists.txt index 2db6f5b6..57b6db2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,7 @@ include_directories(third_party/httplib) include_directories(third_party/stb) include_directories(third_party/opengl) include_directories(third_party/mio/single_include) +include_directories(third_party/imgui-lua-bindings) add_compile_definitions(NOMINMAX) # Make windows.h not define min/max macros because third-party deps don't like it add_compile_definitions(WIN32_LEAN_AND_MEAN) # Make windows.h not include literally everything diff --git a/src/lua.cpp b/src/lua.cpp index ec1287bd..1b2cae63 100644 --- a/src/lua.cpp +++ b/src/lua.cpp @@ -1,6 +1,8 @@ #ifdef PANDA3DS_ENABLE_LUA #include "lua_manager.hpp" +void LoadImguiBindings(lua_State* lState); + void LuaManager::initialize() { L = luaL_newstate(); // Open Lua @@ -12,6 +14,7 @@ void LuaManager::initialize() { luaL_openlibs(L); initializeThunks(); + LoadImguiBindings(L); initialized = true; haveScript = false; @@ -91,7 +94,6 @@ void LuaManager::reset() { // Initialize C++ thunks for Lua code to call here // All code beyond this point is terrible and full of global state, don't judge - Memory* LuaManager::g_memory = nullptr; #define MAKE_MEMORY_FUNCTIONS(size) \ diff --git a/src/panda_qt/main_window.cpp b/src/panda_qt/main_window.cpp index 9c177579..6f20496e 100644 --- a/src/panda_qt/main_window.cpp +++ b/src/panda_qt/main_window.cpp @@ -179,6 +179,14 @@ void MainWindow::emuThreadMainLoop() { } } + SDL_GL_MakeCurrent(nullptr, nullptr); + SDL_GL_MakeCurrent(windowSDL, glContextSDL); + // Start the Dear ImGui frame + ImGui_ImplOpenGL3_NewFrame(); + ImGui_ImplSDL2_NewFrame(windowSDL); + ImGui::NewFrame(); + screen.getGLContext()->MakeCurrent(); + emu->runFrame(); if (emu->romType != ROMType::None) { emu->getServiceManager().getHID().updateInputs(emu->getTicks()); @@ -199,30 +207,7 @@ void MainWindow::emuThreadMainLoop() { ImGui_ImplSDL2_ProcessEvent(&event); } - // Start the Dear ImGui frame - ImGui_ImplOpenGL3_NewFrame(); - ImGui_ImplSDL2_NewFrame(windowSDL); - ImGui::NewFrame(); - - // 1. Show the big demo window (Most of the sample code is in ImGui::ShowDemoWindow()! You can browse its code to learn more about Dear - // ImGui!). bool show_demo_window = true; - // 2. Show a simple window that we create ourselves. We use a Begin/End pair to create a named window. - { - static float f = 0.0f; - static int counter = 0; - - ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it. - - ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too) - ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state - if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated) - counter++; - ImGui::SameLine(); - ImGui::Text("counter = %d", counter); - - ImGui::End(); - } ImGui::ShowDemoWindow(&show_demo_window); ImGui::Render();