Keep rect in memory

Feel better about this than creating one all da time
This commit is contained in:
Sally Coolatta 2022-03-26 17:16:13 -04:00
parent 33f316ded2
commit 417bbd1bf2

View file

@ -1257,6 +1257,10 @@ void I_UpdateNoBlit(void)
static inline boolean I_SkipFrame(void) static inline boolean I_SkipFrame(void)
{ {
#if 1 #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; return false;
#else #else
static boolean skip = false; static boolean skip = false;
@ -1280,6 +1284,8 @@ static inline boolean I_SkipFrame(void)
// //
// I_FinishUpdate // I_FinishUpdate
// //
static SDL_Rect src_rect = { 0, 0, 0, 0 };
void I_FinishUpdate(void) void I_FinishUpdate(void)
{ {
int player; int player;
@ -1340,16 +1346,18 @@ void I_FinishUpdate(void)
{ {
Impl_VideoSetupSDLBuffer(); Impl_VideoSetupSDLBuffer();
} }
if (bufSurface) 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 // Fury -- there's no way around UpdateTexture, the GL backend uses it anyway
SDL_LockSurface(vidSurface); SDL_LockSurface(vidSurface);
SDL_UpdateTexture(texture, &rect, vidSurface->pixels, vidSurface->pitch); SDL_UpdateTexture(texture, &src_rect, vidSurface->pixels, vidSurface->pitch);
SDL_UnlockSurface(vidSurface); SDL_UnlockSurface(vidSurface);
} }
SDL_RenderClear(renderer); SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, texture, NULL, NULL); SDL_RenderCopy(renderer, texture, &src_rect, NULL);
SDL_RenderPresent(renderer); SDL_RenderPresent(renderer);
} }
#ifdef HWRENDER #ifdef HWRENDER
@ -1358,6 +1366,7 @@ void I_FinishUpdate(void)
OglSdlFinishUpdate(cv_vidwait.value); OglSdlFinishUpdate(cv_vidwait.value);
} }
#endif #endif
exposevideo = SDL_FALSE; exposevideo = SDL_FALSE;
} }
@ -1710,6 +1719,9 @@ INT32 VID_SetMode(INT32 modeNum)
vid.height = windowedModes[modeNum][1]; vid.height = windowedModes[modeNum][1];
vid.modenum = modeNum; vid.modenum = modeNum;
src_rect.w = vid.width;
src_rect.h = vid.height;
//Impl_SetWindowName("SRB2Kart "VERSIONSTRING); //Impl_SetWindowName("SRB2Kart "VERSIONSTRING);
VID_CheckRenderer(); VID_CheckRenderer();
return SDL_TRUE; return SDL_TRUE;