From 41997c45490deeb0978a9b73094edd6244fc96c7 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 26 Mar 2022 17:16:13 -0400 Subject: [PATCH] Keep rect in memory Feel better about this than creating one all da time --- src/sdl/i_video.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index f90eb09ae..d8899e932 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -1179,6 +1179,10 @@ void I_UpdateNoBlit(void) static inline boolean I_SkipFrame(void) { #if 1 + // While I fixed the FPS counter bugging out with this, + // I actually really like being able to pause and + // use perfstats to measure rendering performance + // without game logic changes. return false; #else static boolean skip = false; @@ -1203,6 +1207,8 @@ static inline boolean I_SkipFrame(void) // // I_FinishUpdate // +static SDL_Rect src_rect = { 0, 0, 0, 0 }; + void I_FinishUpdate(void) { if (rendermode == render_none) @@ -1228,27 +1234,22 @@ void I_FinishUpdate(void) if (rendermode == render_soft && screens[0]) { - SDL_Rect rect; - - rect.x = 0; - rect.y = 0; - rect.w = vid.width; - rect.h = vid.height; - if (!bufSurface) //Double-Check { Impl_VideoSetupSDLBuffer(); } + if (bufSurface) { - SDL_BlitSurface(bufSurface, NULL, vidSurface, &rect); + SDL_BlitSurface(bufSurface, &src_rect, vidSurface, &src_rect); // Fury -- there's no way around UpdateTexture, the GL backend uses it anyway SDL_LockSurface(vidSurface); - SDL_UpdateTexture(texture, &rect, vidSurface->pixels, vidSurface->pitch); + SDL_UpdateTexture(texture, &src_rect, vidSurface->pixels, vidSurface->pitch); SDL_UnlockSurface(vidSurface); } + SDL_RenderClear(renderer); - SDL_RenderCopy(renderer, texture, NULL, NULL); + SDL_RenderCopy(renderer, texture, &src_rect, NULL); SDL_RenderPresent(renderer); } #ifdef HWRENDER @@ -1257,6 +1258,7 @@ void I_FinishUpdate(void) OglSdlFinishUpdate(cv_vidwait.value); } #endif + exposevideo = SDL_FALSE; } @@ -1610,6 +1612,9 @@ INT32 VID_SetMode(INT32 modeNum) vid.modenum = modeNum; //Impl_SetWindowName("SRB2 "VERSIONSTRING); + src_rect.w = vid.width; + src_rect.h = vid.height; + VID_CheckRenderer(); return SDL_TRUE; }