obcured and game crash on window resize fix

This commit is contained in:
Issac332 2026-07-28 18:11:36 +03:00
parent 1609ba8eb0
commit e9b8d4e16f
5 changed files with 19 additions and 3 deletions

View file

@ -4,7 +4,7 @@ include(FindPackageHandleStandardArgs)
# Options # Options
option(STEAM "Build for Steam" OFF) 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) option(NATIVE "Use native instructions(for local use only)" OFF)
#x86, arm64, ia-64 #x86, arm64, ia-64
option(CPU_ARCH "Enter here your target arch" "x86") option(CPU_ARCH "Enter here your target arch" "x86")

View file

@ -522,7 +522,7 @@ bool EventThread::eventFilter(void *data, SDL_Event *event){
rtData.ethread->winX = event->window.data1; rtData.ethread->winX = event->window.data1;
rtData.ethread->winY = event->window.data2; rtData.ethread->winY = event->window.data2;
shState->windowSignals.moved.Emit(event->window.data1, event->window.data2); shState->windowSignals.moved.Emit(event->window.data1, event->window.data2);
shState->graphics().update(false); //shState->graphics().update(false);
} }
return 0; return 0;
} }

View file

@ -906,6 +906,15 @@ void Graphics::resizeScreen(int width, int height, bool emitSignal){
glState.scissorBox.set(IntRect(0, 0, width, height)); glState.scissorBox.set(IntRect(0, 0, width, height));
shState->eThread().requestWindowResize(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) if (emitSignal)
shState->graphicsSignals.resized.Emit(width, height); shState->graphicsSignals.resized.Emit(width, height);
} }

View file

@ -525,7 +525,7 @@ bool Oneshot::msgbox(int type, const char *body, const char *title)
// Show messagebox // Show messagebox
#ifdef _WIN32 #ifdef _WIN32
PlaySoundW((LPCWSTR)sound, NULL, SND_ALIAS_ID | SND_ASYNC); PlaySoundW(MAKEINTRESOURCEW(sound), NULL, SND_ALIAS_ID | SND_ASYNC);
#endif #endif
int button; int button;
@ -588,6 +588,12 @@ void Oneshot::setObscuredUpdating(bool enabled){
p->obscuredNeedToUpdate = 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) void Oneshot::updateObscured(int winX, int winY)
{ {
SDL_LockMutex(p->winMutex); SDL_LockMutex(p->winMutex);

View file

@ -60,6 +60,7 @@ public:
void setExiting(bool exiting); void setExiting(bool exiting);
void setAllowExit(bool allowExit); void setAllowExit(bool allowExit);
void setObscuredUpdating(bool enabled); void setObscuredUpdating(bool enabled);
void updateObscuredSize(int winW, int winH);
void updateObscured(int winX, int winY); void updateObscured(int winX, int winY);
void resetObscured(); void resetObscured();