From 7efc3adf6ffb3d29236ba85cc9d77c4e473ffe9e Mon Sep 17 00:00:00 2001 From: NepDisk Date: Sat, 18 Oct 2025 16:05:01 -0400 Subject: [PATCH] [Patch] vid.buffer --- src/screen.h | 1 - src/sdl/i_video.cpp | 35 +---------------------------------- src/v_video.c | 12 +++++++++--- 3 files changed, 10 insertions(+), 38 deletions(-) diff --git a/src/screen.h b/src/screen.h index 6a911748c..1d4333111 100644 --- a/src/screen.h +++ b/src/screen.h @@ -61,7 +61,6 @@ struct viddef_t // screens[3] = fade screen start // screens[4] = fade screen end, postimage tempoarary buffer - UINT8 *buffer; // invisible screens buffer size_t rowbytes; // bytes per scanline of the VIDEO mode INT32 width; // PIXELS per scanline INT32 height; diff --git a/src/sdl/i_video.cpp b/src/sdl/i_video.cpp index a60ea21a6..db017f4fa 100644 --- a/src/sdl/i_video.cpp +++ b/src/sdl/i_video.cpp @@ -142,8 +142,6 @@ static SDL_bool Impl_CreateWindow(SDL_bool fullscreen); static void Impl_VideoSetupSurfaces(int width, int height); -static void Impl_SetupSoftwareBuffer(void); - static void Impl_InitOpenGL(void); #if defined(HAVE_IMAGE) @@ -305,28 +303,6 @@ static void Impl_VideoSetupSurfaces(int width, int height) texture = SDL_CreateTexture(renderer, sw_texture_format, SDL_TEXTUREACCESS_STREAMING, width, height); } -static void Impl_SetupSoftwareBuffer(void) -{ - // Set up game's software render buffer - size_t size; - - vid.rowbytes = vid.width; - - free(vid.buffer); - - size = vid.rowbytes*vid.height * NUMSCREENS; - vid.buffer = static_cast(malloc(size)); - - if (vid.buffer) - { - // Clear the buffer - // HACK: Wasn't sure where else to put this. - memset(vid.buffer, 31, size); - } - else - I_Error("%s", M_GetText("Not enough memory for video buffer\n")); -} - static SDL_Rect src_rect = { 0, 0, 0, 0 }; static SDL_bool SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen, SDL_bool reposition) @@ -380,12 +356,6 @@ static SDL_bool SDLSetMode(INT32 width, INT32 height, SDL_bool fullscreen, SDL_b if (Impl_RenderContextReset() == SDL_FALSE) I_Error("Couldn't create or reset rendering context"); - if (vid.buffer) - { - free(vid.buffer); - vid.buffer = NULL; - } - return SDL_TRUE; } @@ -1514,7 +1484,7 @@ boolean VID_CheckRenderer(void) if (rendermode == render_soft) { - Impl_SetupSoftwareBuffer(); + vid.rowbytes = vid.width; SCR_SetDrawFuncs(); } #ifdef HWRENDER @@ -1822,9 +1792,6 @@ void I_ShutdownGraphics(void) icoSurface = NULL; #endif - free(vid.buffer); - vid.buffer = NULL; - rendermode = render_none; I_OutputMsg("I_ShutdownGraphics(): "); diff --git a/src/v_video.c b/src/v_video.c index a8be1fdd3..f710528e9 100644 --- a/src/v_video.c +++ b/src/v_video.c @@ -3882,17 +3882,23 @@ UINT8 GetColorLUTDirect(colorlookup_t *lut, UINT8 r, UINT8 g, UINT8 b) void V_Init(void) { INT32 i; - UINT8 *base = vid.buffer; const INT32 screensize = vid.rowbytes * vid.height; for (i = 0; i < NUMSCREENS; i++) + { + if (vid.screens[i]) + free(vid.screens[i]); vid.screens[i] = NULL; + } // start address of NUMSCREENS * width*height vidbuffers - if (base) + if (screensize > 0) { for (i = 0; i < NUMSCREENS; i++) - vid.screens[i] = base + i*screensize; + { + vid.screens[i] = malloc(screensize); + memset(vid.screens[i], 0, screensize); + } } #ifdef DEBUG