fix Windows builds under MSYS2 CLANG64 #1

Merged
tsuki merged 1 commits from bloogoop/openroller:msys2-builds into main 2026-08-05 18:13:16 +00:00
3 changed files with 41 additions and 4 deletions
@@ -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<ActiveTextureProc>(
SDL_GL_GetProcAddress("glActiveTexture"));
if (activeTexture) activeTexture(texture);
}
+2 -1
View File
@@ -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_);
+29 -3
View File
@@ -14,8 +14,13 @@
#include <filesystem>
#include <limits>
#include <string_view>
#ifdef _WIN32
#include <windows.h>
#include <process.h>
#else
#include <limits.h>
#include <unistd.h>
#endif
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/quaternion.hpp>
@@ -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<float>(kGameWidth),
static_cast<float>(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<char*>(nullptr));
} else if (gameplayItem == GcGameplayItem::Reverse) {
_execl(executable, executable, "--item", "reverse",
"--menu", root.c_str(), static_cast<char*>(nullptr));
} else {
_execl(executable, executable, "--menu", root.c_str(),
static_cast<char*>(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;
}