mirror of
https://github.com/fabiangreffrath/woof.git
synced 2025-09-22 19:38:06 -04:00
factor calculation for upscaled_texture from Crispy Doom (#1019)
* factor calculation for upscaled_texture from Crispy Doom * use SDL_GetDesktopDisplayMode istead of SDL_GetRendererOutputSize
This commit is contained in:
parent
90c3df526c
commit
8a0bb50eca
@ -1423,6 +1423,64 @@ void I_GetScreenDimensions(void)
|
||||
WIDESCREENDELTA = (SCREENWIDTH - NONWIDEWIDTH) / 2;
|
||||
}
|
||||
|
||||
static void CreateUpscaledTexture(int v_w, int v_h)
|
||||
{
|
||||
SDL_RendererInfo info;
|
||||
SDL_DisplayMode mode;
|
||||
int w_upscale, h_upscale;
|
||||
|
||||
SDL_GetRendererInfo(renderer, &info);
|
||||
|
||||
if (info.flags & SDL_RENDERER_SOFTWARE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_GetDesktopDisplayMode(video_display, &mode);
|
||||
|
||||
// Pick texture size the next integer multiple of the screen dimensions.
|
||||
// If one screen dimension matches an integer multiple of the original
|
||||
// resolution, there is no need to overscale in this direction.
|
||||
|
||||
w_upscale = (mode.w + v_w - 1) / v_w;
|
||||
h_upscale = (mode.h + v_h - 1) / v_h;
|
||||
|
||||
while (w_upscale * v_w > info.max_texture_width)
|
||||
{
|
||||
--w_upscale;
|
||||
}
|
||||
while (h_upscale * v_h > info.max_texture_height)
|
||||
{
|
||||
--h_upscale;
|
||||
}
|
||||
|
||||
if (w_upscale < 1)
|
||||
{
|
||||
w_upscale = 1;
|
||||
}
|
||||
if (h_upscale < 1)
|
||||
{
|
||||
h_upscale = 1;
|
||||
}
|
||||
|
||||
if (texture_upscaled != NULL)
|
||||
{
|
||||
SDL_DestroyTexture(texture_upscaled);
|
||||
}
|
||||
|
||||
// Set the scaling quality for rendering the upscaled texture
|
||||
// to "linear", which looks much softer and smoother than "nearest"
|
||||
// but does a better job at downscaling from the upscaled texture to
|
||||
// screen.
|
||||
|
||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
|
||||
|
||||
texture_upscaled = SDL_CreateTexture(renderer,
|
||||
SDL_GetWindowPixelFormat(screen),
|
||||
SDL_TEXTUREACCESS_TARGET,
|
||||
w_upscale* v_w, h_upscale * v_h);
|
||||
}
|
||||
|
||||
//
|
||||
// killough 11/98: New routine, for setting hires and page flipping
|
||||
//
|
||||
@ -1757,29 +1815,7 @@ static void I_InitGraphicsMode(void)
|
||||
|
||||
if (bilinear_sharpening)
|
||||
{
|
||||
SDL_RendererInfo info;
|
||||
|
||||
SDL_GetRendererInfo(renderer, &info);
|
||||
|
||||
if (!(info.flags & SDL_RENDERER_SOFTWARE))
|
||||
{
|
||||
if (texture_upscaled != NULL)
|
||||
{
|
||||
SDL_DestroyTexture(texture_upscaled);
|
||||
}
|
||||
|
||||
// Set the scaling quality for rendering the upscaled texture
|
||||
// to "linear", which looks much softer and smoother than "nearest"
|
||||
// but does a better job at downscaling from the upscaled texture to
|
||||
// screen.
|
||||
|
||||
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
|
||||
|
||||
texture_upscaled = SDL_CreateTexture(renderer,
|
||||
pixel_format,
|
||||
SDL_TEXTUREACCESS_TARGET,
|
||||
v_w * 2, v_h * 2);
|
||||
}
|
||||
CreateUpscaledTexture(v_w, v_h);
|
||||
}
|
||||
|
||||
UpdateGrab();
|
||||
|
Loading…
x
Reference in New Issue
Block a user