mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 23:32:09 +00:00
[renderer] Respond to window size changes
Currently, only gl, glsl and sw are working, vulkan needs its swapchain to be rebuilt, and there are minor issues with the hud and console resizing.
This commit is contained in:
parent
ef8b267826
commit
f758f5fb70
3 changed files with 41 additions and 10 deletions
|
@ -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 ();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue