From 0b8d30bac412e0cfc691ad6aab3a105e997991d5 Mon Sep 17 00:00:00 2001 From: Bloo Goop Date: Tue, 4 Aug 2026 12:27:10 +0700 Subject: [PATCH] fix Windows builds under MSYS2 - Use Windows executable-path APIs when returning to the song menu - Add an SDL-based OpenGL compatibility helper for glActiveTexture so it resolves at runtime instead of linking against the OpenGL 1.1-only Windows import library --- .../include/openroller/desktop/GlCompat.hpp | 10 ++++++ apps/desktop/src/ServiceMenu.cpp | 3 +- apps/desktop/src/main.cpp | 32 +++++++++++++++++-- 3 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 apps/desktop/include/openroller/desktop/GlCompat.hpp diff --git a/apps/desktop/include/openroller/desktop/GlCompat.hpp b/apps/desktop/include/openroller/desktop/GlCompat.hpp new file mode 100644 index 0000000..374937d --- /dev/null +++ b/apps/desktop/include/openroller/desktop/GlCompat.hpp @@ -0,0 +1,10 @@ +#pragma once + +#include "vectorail/core/gl_loader.hpp" + +inline void ActivateTexture(GLenum texture) { + using ActiveTextureProc = void(APIENTRY *)(GLenum); + static const auto activeTexture = reinterpret_cast( + SDL_GL_GetProcAddress("glActiveTexture")); + if (activeTexture) activeTexture(texture); +} diff --git a/apps/desktop/src/ServiceMenu.cpp b/apps/desktop/src/ServiceMenu.cpp index d501747..233087f 100644 --- a/apps/desktop/src/ServiceMenu.cpp +++ b/apps/desktop/src/ServiceMenu.cpp @@ -1,6 +1,7 @@ #include "openroller/desktop/ServiceMenu.hpp" #include "openroller/desktop/CabinetBackend.hpp" +#include "openroller/desktop/GlCompat.hpp" #include "vectorail/core/Shader.hpp" #include "vectorail/core/gl_loader.hpp" @@ -109,7 +110,7 @@ public: shader_.setBool("uUseTexture", true); shader_.setBool("uUseGradient", false); shader_.setVec4("uColor", color); - glActiveTexture(GL_TEXTURE0); + ActivateTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, activeTexture); glBindVertexArray(vao_); glBindBuffer(GL_ARRAY_BUFFER, vbo_); diff --git a/apps/desktop/src/main.cpp b/apps/desktop/src/main.cpp index b99987b..401cbd3 100644 --- a/apps/desktop/src/main.cpp +++ b/apps/desktop/src/main.cpp @@ -14,8 +14,13 @@ #include #include #include +#ifdef _WIN32 +#include +#include +#else #include #include +#endif #include #include #include @@ -23,6 +28,7 @@ #include "vectorail/core/Shader.hpp" #include "openroller/desktop/LevelLoader.hpp" #include "openroller/desktop/AudioManager.hpp" +#include "openroller/desktop/GlCompat.hpp" #include "vectorail/core/DdsTexture.hpp" #include "gc/GcTargetEffect.hpp" #include "vectorail/core/PngTexture.hpp" @@ -2077,7 +2083,7 @@ int main(int argc, char* argv[]) { noteShader.use(); noteShader.setMat4("uProjection", proj); noteShader.setInt("uTexture", 0); - glActiveTexture(GL_TEXTURE0); + ActivateTexture(GL_TEXTURE0); glBindVertexArray(noteSpriteVAO); for (const MarkerDraw& marker : markerDraws) { if (marker.effectId <= 0 || marker.uvRecordBase < 0) continue; @@ -2169,7 +2175,7 @@ int main(int argc, char* argv[]) { noteShader.use(); noteShader.setMat4("uProjection", proj); noteShader.setInt("uTexture", 0); - glActiveTexture(GL_TEXTURE0); + ActivateTexture(GL_TEXTURE0); glBindVertexArray(noteSpriteVAO); glDepthMask(GL_FALSE); glBlendFunc(GL_SRC_ALPHA, GL_ONE); @@ -2250,7 +2256,7 @@ int main(int argc, char* argv[]) { glm::ortho(0.0f, static_cast(kGameWidth), static_cast(kGameHeight), 0.0f, -1.0f, 1.0f)); noteShader.setInt("uTexture", 0); - glActiveTexture(GL_TEXTURE0); + ActivateTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, helperAtlas.id); glBindVertexArray(noteSpriteVAO); const glm::mat4 helperRoot = glm::scale( @@ -2328,6 +2334,25 @@ int main(int argc, char* argv[]) { } for (SDL_Gamepad* gamepad : gamepads) SDL_CloseGamepad(gamepad); if (chartCompleted && !gcRoot.empty()) { +#ifdef _WIN32 + char executable[MAX_PATH]{}; + const DWORD length = GetModuleFileNameA(nullptr, executable, sizeof(executable)); + if (length > 0 && length < sizeof(executable)) { + const std::string root = gcRoot.string(); + if (gameplayItem == GcGameplayItem::Mirror) { + _execl(executable, executable, "--item", "mirror", + "--menu", root.c_str(), static_cast(nullptr)); + } else if (gameplayItem == GcGameplayItem::Reverse) { + _execl(executable, executable, "--item", "reverse", + "--menu", root.c_str(), static_cast(nullptr)); + } else { + _execl(executable, executable, "--menu", root.c_str(), + static_cast(nullptr)); + } + std::cerr << "Could not return to song menu: " + << std::strerror(errno) << std::endl; + } +#else char executable[PATH_MAX]{}; const ssize_t length = readlink( "/proc/self/exe", executable, sizeof(executable) - 1); @@ -2347,6 +2372,7 @@ int main(int argc, char* argv[]) { std::cerr << "Could not return to song menu: " << std::strerror(errno) << std::endl; } +#endif } return 0; } -- 2.54.0