1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 17:49:43 +01:00

Fix regression: Linear filter persistence

This fixes #1013 by axing the use of SDL_HINT_RENDER_SCALE_QUALITY and
instead using SDL_SetTextureScaleMode.

The hint is unwieldy to use, and since #923, has resulted in a
regression where starting the game in filtered mode then switching to
nearest results in scaled textures still being filtered.

The proper solution is to use SDL_SetTextureScaleMode on the two
textures that are drawn to the final screen: gameTexture and
tempShakeTexture.
This commit is contained in:
Misa 2023-09-09 20:00:05 -07:00
parent 5467dbe3d8
commit 1bf0d11c9e
2 changed files with 37 additions and 10 deletions

View file

@ -194,6 +194,16 @@ void Graphics::create_buffers(void)
#undef CREATE_SCROLL_TEXTURE #undef CREATE_SCROLL_TEXTURE
#undef CREATE_TEXTURE #undef CREATE_TEXTURE
#undef CREATE_TEXTURE_WITH_DIMENSIONS #undef CREATE_TEXTURE_WITH_DIMENSIONS
SDL_SetTextureScaleMode(
gameTexture,
gameScreen.isFiltered ? SDL_ScaleModeLinear : SDL_ScaleModeNearest
);
SDL_SetTextureScaleMode(
tempShakeTexture,
gameScreen.isFiltered ? SDL_ScaleModeLinear : SDL_ScaleModeNearest
);
} }
void Graphics::destroy_buffers(void) void Graphics::destroy_buffers(void)

View file

@ -39,11 +39,6 @@ void Screen::init(const struct ScreenSettings* settings)
badSignalEffect = settings->badSignal; badSignalEffect = settings->badSignal;
vsync = settings->useVsync; vsync = settings->useVsync;
SDL_SetHintWithPriority(
SDL_HINT_RENDER_SCALE_QUALITY,
isFiltered ? "linear" : "nearest",
SDL_HINT_OVERRIDE
);
SDL_SetHintWithPriority( SDL_SetHintWithPriority(
SDL_HINT_RENDER_VSYNC, SDL_HINT_RENDER_VSYNC,
vsync ? "1" : "0", vsync ? "1" : "0",
@ -313,12 +308,10 @@ void Screen::toggleScalingMode(void)
void Screen::toggleLinearFilter(void) void Screen::toggleLinearFilter(void)
{ {
isFiltered = !isFiltered; isFiltered = !isFiltered;
SDL_SetHintWithPriority(
SDL_HINT_RENDER_SCALE_QUALITY,
isFiltered ? "linear" : "nearest",
SDL_HINT_OVERRIDE
);
SDL_DestroyTexture(graphics.gameTexture); SDL_DestroyTexture(graphics.gameTexture);
SDL_DestroyTexture(graphics.tempShakeTexture);
graphics.gameTexture = SDL_CreateTexture( graphics.gameTexture = SDL_CreateTexture(
m_renderer, m_renderer,
SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888,
@ -327,11 +320,35 @@ void Screen::toggleLinearFilter(void)
SCREEN_HEIGHT_PIXELS SCREEN_HEIGHT_PIXELS
); );
graphics.tempShakeTexture = SDL_CreateTexture(
m_renderer,
SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_TARGET,
SCREEN_WIDTH_PIXELS,
SCREEN_HEIGHT_PIXELS
);
if (graphics.gameTexture == NULL) if (graphics.gameTexture == NULL)
{ {
vlog_error("Could not create game texture: %s", SDL_GetError()); vlog_error("Could not create game texture: %s", SDL_GetError());
return; return;
} }
if (graphics.tempShakeTexture == NULL)
{
vlog_error("Could not create temp shake texture: %s", SDL_GetError());
return;
}
SDL_SetTextureScaleMode(
graphics.gameTexture,
isFiltered ? SDL_ScaleModeLinear : SDL_ScaleModeNearest
);
SDL_SetTextureScaleMode(
graphics.tempShakeTexture,
isFiltered ? SDL_ScaleModeLinear : SDL_ScaleModeNearest
);
} }
void Screen::toggleVSync(void) void Screen::toggleVSync(void)