From 77d2a84af8e8cdd7372e930c2c1ea8b0c071ffb6 Mon Sep 17 00:00:00 2001 From: redpolline <11156324-redpolline@users.noreply.gitlab.com> Date: Fri, 15 Nov 2024 13:14:39 -0500 Subject: [PATCH] Wine + Enscripten fixes for OpenGL_Hook.cpp. --- overlay_experimental/windows/OpenGL_Hook.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/overlay_experimental/windows/OpenGL_Hook.cpp b/overlay_experimental/windows/OpenGL_Hook.cpp index e88de9d..43e4050 100644 --- a/overlay_experimental/windows/OpenGL_Hook.cpp +++ b/overlay_experimental/windows/OpenGL_Hook.cpp @@ -163,12 +163,7 @@ std::weak_ptr OpenGL_Hook::CreateImageResource(const void* image_data, { GLuint* texture = new GLuint(0); glGenTextures(1, texture); - if (glGetError() != GL_NO_ERROR) - { - delete texture; - return std::shared_ptr(nullptr); - } - + // Save old texture id GLint oldTex; glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTex); @@ -177,13 +172,17 @@ std::weak_ptr OpenGL_Hook::CreateImageResource(const void* image_data, glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); // Upload pixels into texture +#if defined(GL_UNPACK_ROW_LENGTH) && !defined(__EMSCRIPTEN__) glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); +#endif + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image_data); - glBindTexture(GL_TEXTURE_2D, oldTex); - + glFlush(); auto ptr = std::shared_ptr((uint64_t*)texture, [](uint64_t* handle) { if (handle != nullptr)