diff --git a/libs/video/renderer/r_screen.c b/libs/video/renderer/r_screen.c index 4106220f8..541cb3abb 100644 --- a/libs/video/renderer/r_screen.c +++ b/libs/video/renderer/r_screen.c @@ -183,6 +183,7 @@ SCR_CalcRefdef (void) // force a background redraw r_data->scr_fullupdate = 0; + r_funcs->bind_framebuffer (0); } static void @@ -435,6 +436,21 @@ viewsize_listener (void *data, const cvar_t *cvar) update_vrect (); } +static void +vidsize_listener (void *data, const viddef_t *vdef) +{ + update_vrect (); + if (fisheye_cube_map) { + r_funcs->destroy_frame_buffer (fisheye_cube_map); + fisheye_cube_map = 0; + } + if (warp_buffer) { + r_funcs->destroy_frame_buffer (warp_buffer); + warp_buffer = 0; + } + r_funcs->set_fov (tan_fov_x, tan_fov_y); +} + void SCR_Init (void) { @@ -453,6 +469,7 @@ SCR_Init (void) cvar_t *var = Cvar_FindVar ("viewsize"); Cvar_AddListener (var, viewsize_listener, 0); + VID_OnVidResize_AddListener (vidsize_listener, 0); update_vrect (); } diff --git a/libs/video/renderer/sw/d_init.c b/libs/video/renderer/sw/d_init.c index e5daaf439..b7e475ac1 100644 --- a/libs/video/renderer/sw/d_init.c +++ b/libs/video/renderer/sw/d_init.c @@ -49,6 +49,22 @@ static byte *surfcache; void (*d_drawspans) (espan_t *pspan); +static void +d_vidsize_listener (void *data, const viddef_t *vid) +{ + int cachesize = D_SurfaceCacheForRes (vid->width, vid->height); + + if (surfcache) { + D_FlushCaches (vid->vid_internal->data); + free (surfcache); + surfcache = 0; + } + surfcache = calloc (cachesize, 1); + vid->vid_internal->init_buffers (vid->vid_internal->data); + D_InitCaches (surfcache, cachesize); + + viddef.recalc_refdef = 1; +} void D_Init (void) @@ -61,16 +77,8 @@ D_Init (void) vid->vid_internal->flush_caches = D_FlushCaches; - int cachesize = D_SurfaceCacheForRes (vid->width, vid->height); - - if (surfcache) { - D_FlushCaches (vid->vid_internal->data); - free (surfcache); - surfcache = 0; - } - surfcache = calloc (cachesize, 1); - vid->vid_internal->init_buffers (vid->vid_internal->data); - D_InitCaches (surfcache, cachesize); + VID_OnVidResize_AddListener (d_vidsize_listener, 0); + d_vidsize_listener (0, vr_data.vid); } void diff --git a/libs/video/targets/vid_x11_sw.c b/libs/video/targets/vid_x11_sw.c index 658a11ac2..3d5ef4526 100644 --- a/libs/video/targets/vid_x11_sw.c +++ b/libs/video/targets/vid_x11_sw.c @@ -640,13 +640,19 @@ x11_init_buffers (void *data) if (x_visinfo->depth != 8) { if (swfb.color) free (swfb.color); + if (swfb.depth) + free (swfb.depth); swfb.rowbytes = viddef.width; swfb.color = calloc (swfb.rowbytes, viddef.height); + swfb.depth = 0; if (!swfb.color) Sys_Error ("Not enough memory for video mode"); } else { swfb.rowbytes = x_framebuffer[current_framebuffer]->bytes_per_line; swfb.color = (byte *) x_framebuffer[current_framebuffer]->data; + if (swfb.depth) + free (swfb.depth); + swfb.depth = 0; } }