From e9b8d4e16f31f366b1ec3c358b6ef6964ce32a4a Mon Sep 17 00:00:00 2001 From: Issac332 <119879937+Issac8658@users.noreply.github.com> Date: Tue, 28 Jul 2026 18:11:36 +0300 Subject: [PATCH] obcured and game crash on window resize fix --- CMakeLists.txt | 2 +- src/eventthread.cpp | 2 +- src/graphics.cpp | 9 +++++++++ src/oneshot.cpp | 8 +++++++- src/oneshot.h | 1 + 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0865f27..a09d1a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ include(FindPackageHandleStandardArgs) # Options option(STEAM "Build for Steam" OFF) -option(DEBUG "Debug mode" OFF) +option(DEBUG "Debug mode" ON) option(NATIVE "Use native instructions(for local use only)" OFF) #x86, arm64, ia-64 option(CPU_ARCH "Enter here your target arch" "x86") diff --git a/src/eventthread.cpp b/src/eventthread.cpp index cda4067..418f109 100644 --- a/src/eventthread.cpp +++ b/src/eventthread.cpp @@ -522,7 +522,7 @@ bool EventThread::eventFilter(void *data, SDL_Event *event){ rtData.ethread->winX = event->window.data1; rtData.ethread->winY = event->window.data2; shState->windowSignals.moved.Emit(event->window.data1, event->window.data2); - shState->graphics().update(false); + //shState->graphics().update(false); } return 0; } diff --git a/src/graphics.cpp b/src/graphics.cpp index e0d1e14..4312cfe 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -906,6 +906,15 @@ void Graphics::resizeScreen(int width, int height, bool emitSignal){ glState.scissorBox.set(IntRect(0, 0, width, height)); shState->eThread().requestWindowResize(width, height); + + TEX::del(p->obscuredTex); + p->obscuredTex = TEX::gen(); + TEX::bind(p->obscuredTex); + TEX::setRepeat(false); + TEX::setSmooth(false); + gl.TexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE8, p->scRes.x, p->scRes.y, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, 0); + shState->oneshot().updateObscuredSize(size.x, size.y); + if (emitSignal) shState->graphicsSignals.resized.Emit(width, height); } diff --git a/src/oneshot.cpp b/src/oneshot.cpp index 238c3c6..0fb308d 100644 --- a/src/oneshot.cpp +++ b/src/oneshot.cpp @@ -525,7 +525,7 @@ bool Oneshot::msgbox(int type, const char *body, const char *title) // Show messagebox #ifdef _WIN32 - PlaySoundW((LPCWSTR)sound, NULL, SND_ALIAS_ID | SND_ASYNC); + PlaySoundW(MAKEINTRESOURCEW(sound), NULL, SND_ALIAS_ID | SND_ASYNC); #endif int button; @@ -588,6 +588,12 @@ void Oneshot::setObscuredUpdating(bool enabled){ p->obscuredNeedToUpdate = enabled; } +void Oneshot::updateObscuredSize(int winW, int winH){ + p->winW = winW; + p->winH = winH; + p->obscuredMap.resize(p->winW * p->winH, 255); +} + void Oneshot::updateObscured(int winX, int winY) { SDL_LockMutex(p->winMutex); diff --git a/src/oneshot.h b/src/oneshot.h index 607ce86..ed0395e 100644 --- a/src/oneshot.h +++ b/src/oneshot.h @@ -60,6 +60,7 @@ public: void setExiting(bool exiting); void setAllowExit(bool allowExit); void setObscuredUpdating(bool enabled); + void updateObscuredSize(int winW, int winH); void updateObscured(int winX, int winY); void resetObscured();