From 1882fc2dbc37b9dd02e1c1ef51d058e20f6403bd Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Mon, 1 Feb 2021 23:02:51 +0200 Subject: [PATCH 1/4] #661: Use corrected resolution in fullscreen=1 --- src/client/refresh/soft/sw_main.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/client/refresh/soft/sw_main.c b/src/client/refresh/soft/sw_main.c index 78e7851b..fdefe0b3 100644 --- a/src/client/refresh/soft/sw_main.c +++ b/src/client/refresh/soft/sw_main.c @@ -2285,6 +2285,21 @@ SWimp_SetMode(int *pwidth, int *pheight, int mode, int fullscreen ) R_Printf(PRINT_ALL, " %dx%d (vid_fullscreen %i)\n", *pwidth, *pheight, fullscreen); + if (fullscreen == 1) + { + int real_height, real_width; + + if(ri.GLimp_GetDesktopMode(&real_width, &real_height)) + { + if (real_height) + { + *pwidth = (*pheight) * real_width / real_height; + } + } + + R_Printf(PRINT_ALL, " Used corrected %dx%d mode\n", *pwidth, *pheight); + } + if (!ri.GLimp_InitGraphics(fullscreen, pwidth, pheight)) { // failed to set a valid mode in windowed mode From 0b79fa99ed54b64a87d3b53362f02130d319bdb7 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Wed, 3 Feb 2021 00:08:10 +0200 Subject: [PATCH 2/4] #660: convert wrong modeltype to warning --- src/client/refresh/soft/sw_draw.c | 4 +++- src/client/refresh/soft/sw_main.c | 24 ++++++++++++++++++------ src/client/refresh/vk/vk_rmain.c | 10 ++++++---- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/client/refresh/soft/sw_draw.c b/src/client/refresh/soft/sw_draw.c index 76d865d6..6339e4db 100644 --- a/src/client/refresh/soft/sw_draw.c +++ b/src/client/refresh/soft/sw_draw.c @@ -177,7 +177,9 @@ RE_Draw_StretchPicImplementation (int x, int y, int w, int h, const image_t *pic (x + w > vid.width) || (y + h > vid.height)) { - ri.Sys_Error(ERR_FATAL, "%s: bad coordinates", __func__); + R_Printf(PRINT_ALL, "%s: bad coordinates %dx%d[%dx%d]", + __func__, x, y, w, h); + return; } VID_DamageBuffer(x, y); diff --git a/src/client/refresh/soft/sw_main.c b/src/client/refresh/soft/sw_main.c index fdefe0b3..0d0bcc00 100644 --- a/src/client/refresh/soft/sw_main.c +++ b/src/client/refresh/soft/sw_main.c @@ -855,8 +855,13 @@ R_DrawEntitiesOnList (void) R_AliasDrawModel(currententity, currentmodel); break; - default: + case mod_brush: break; + + default: + R_Printf(PRINT_ALL, "%s: Bad modeltype %d\n", + __func__, currentmodel->type); + return; } } } @@ -900,8 +905,13 @@ R_DrawEntitiesOnList (void) R_AliasDrawModel(currententity, currentmodel); break; - default: + case mod_brush: break; + + default: + R_Printf(PRINT_ALL, "%s: Bad modeltype %d\n", + __func__, currentmodel->type); + return; } } } @@ -1453,7 +1463,8 @@ RE_BeginFrame( float camera_separation ) // we need redraw everything VID_WholeDamageBuffer(); // and backbuffer should be zeroed - memset(swap_buffers + ((swap_current + 1)&1), 0, vid.height * vid.width * sizeof(pixel_t)); + memset(swap_buffers + ((swap_current + 1)&1), 0, + vid.height * vid.width * sizeof(pixel_t)); vid_gamma->modified = false; sw_overbrightbits->modified = false; @@ -2140,7 +2151,8 @@ RE_CleanFrame(void) int pitch; Uint32 *pixels; - memset(swap_buffers, 0, vid.height * vid.width * sizeof(pixel_t) * 2); + memset(swap_buffers, 0, + vid.height * vid.width * sizeof(pixel_t) * 2); if (SDL_LockTexture(texture, NULL, (void**)&pixels, &pitch)) { @@ -2291,9 +2303,9 @@ SWimp_SetMode(int *pwidth, int *pheight, int mode, int fullscreen ) if(ri.GLimp_GetDesktopMode(&real_width, &real_height)) { - if (real_height) + if (real_height && (real_height != *pheight)) { - *pwidth = (*pheight) * real_width / real_height; + *pwidth = ((*pheight) * real_width) / real_height; } } diff --git a/src/client/refresh/vk/vk_rmain.c b/src/client/refresh/vk/vk_rmain.c index bd3930e8..d0087dea 100644 --- a/src/client/refresh/vk/vk_rmain.c +++ b/src/client/refresh/vk/vk_rmain.c @@ -355,8 +355,9 @@ void R_DrawEntitiesOnList (void) R_DrawSpriteModel(currententity, currentmodel); break; default: - ri.Sys_Error(ERR_DROP, "%s, Bad modeltype", __func__); - break; + R_Printf(PRINT_ALL, "%s: Bad modeltype %d\n", + __func__, currentmodel->type); + return; } } } @@ -394,8 +395,9 @@ void R_DrawEntitiesOnList (void) R_DrawSpriteModel(currententity, currentmodel); break; default: - ri.Sys_Error(ERR_DROP, "%s, Bad modeltype", __func__); - break; + R_Printf(PRINT_ALL, "%s: Bad modeltype %d\n", + __func__, currentmodel->type); + return; } } } From ba173e68b51dc9e097a76d3231b0949970ca3e20 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Sat, 6 Feb 2021 22:42:15 +0200 Subject: [PATCH 3/4] rearrange init functions --- src/client/refresh/soft/sw_main.c | 64 ++++++++++++++++--------------- 1 file changed, 33 insertions(+), 31 deletions(-) diff --git a/src/client/refresh/soft/sw_main.c b/src/client/refresh/soft/sw_main.c index 0d0bcc00..cc7040a6 100644 --- a/src/client/refresh/soft/sw_main.c +++ b/src/client/refresh/soft/sw_main.c @@ -345,12 +345,12 @@ R_InitTurb ================ */ static void -R_InitTurb (void) +R_InitTurb (int width) { int i; - memset(blanktable, 0, (vid.width+CYCLE) * sizeof(int)); - for (i = 0; i < (vid.width+CYCLE); i++) + memset(blanktable, 0, (width+CYCLE) * sizeof(int)); + for (i = 0; i < (width+CYCLE); i++) { sintable[i] = AMP + sin(i*3.14159*2/CYCLE)*AMP; intsintable[i] = AMP2 + sin(i*3.14159*2/CYCLE)*AMP2; // AMP2, not 20 @@ -429,7 +429,7 @@ R_UnRegister (void) } static void RE_ShutdownContext(void); -static void SWimp_CreateRender(void); +static void SWimp_CreateRender(int width, int height); static int RE_InitContext(void *win); static qboolean RE_SetMode(void); @@ -1410,9 +1410,6 @@ RE_RenderFrame (refdef_t *fd) static void R_InitGraphics( int width, int height ) { - vid.width = width; - vid.height = height; - // free z buffer if ( d_pzbuffer ) { @@ -1428,7 +1425,7 @@ R_InitGraphics( int width, int height ) sc_base = NULL; } - d_pzbuffer = malloc(vid.width * vid.height * sizeof(zvalue_t)); + d_pzbuffer = malloc(width * height * sizeof(zvalue_t)); R_InitCaches(); @@ -1499,8 +1496,6 @@ RE_SetMode(void) */ if ((err = SWimp_SetMode(&vid.width, &vid.height, r_mode->value, fullscreen)) == rserr_ok) { - R_InitGraphics( vid.width, vid.height ); - if (r_mode->value == -1) { sw_state.prev_mode = 4; /* safe default for custom mode */ @@ -1514,8 +1509,6 @@ RE_SetMode(void) { if (err == rserr_invalid_fullscreen) { - R_InitGraphics( vid.width, vid.height ); - ri.Cvar_SetValue("vid_fullscreen", 0); vid_fullscreen->modified = false; R_Printf(PRINT_ALL, "%s() - fullscreen unavailable in this mode\n", __func__); @@ -1943,6 +1936,9 @@ RE_InitContext(void *win) SDL_TEXTUREACCESS_STREAMING, vid.width, vid.height); + R_InitGraphics(vid.width, vid.height); + SWimp_CreateRender(vid.width, vid.height); + return true; } @@ -2303,13 +2299,20 @@ SWimp_SetMode(int *pwidth, int *pheight, int mode, int fullscreen ) if(ri.GLimp_GetDesktopMode(&real_width, &real_height)) { - if (real_height && (real_height != *pheight)) + if (real_height) { - *pwidth = ((*pheight) * real_width) / real_height; + if (real_height != *pheight) + { + *pwidth = ((*pheight) * real_width) / real_height; + } + else + { + *pwidth = real_width; + } } } - R_Printf(PRINT_ALL, " Used corrected %dx%d mode\n", *pwidth, *pheight); + R_Printf(PRINT_ALL, "Used corrected %dx%d mode\n", *pwidth, *pheight); } if (!ri.GLimp_InitGraphics(fullscreen, pwidth, pheight)) @@ -2318,16 +2321,14 @@ SWimp_SetMode(int *pwidth, int *pheight, int mode, int fullscreen ) return rserr_invalid_mode; } - SWimp_CreateRender(); - return retval; } static void -SWimp_CreateRender(void) +SWimp_CreateRender(int width, int height) { swap_current = 0; - swap_buffers = malloc(vid.height * vid.width * sizeof(pixel_t) * 2); + swap_buffers = malloc(height * width * sizeof(pixel_t) * 2); if (!swap_buffers) { ri.Sys_Error(ERR_FATAL, "%s: Can't allocate swapbuffer.", __func__); @@ -2335,20 +2336,20 @@ SWimp_CreateRender(void) return; } swap_frames[0] = swap_buffers; - swap_frames[1] = swap_buffers + vid.height * vid.width * sizeof(pixel_t); + swap_frames[1] = swap_buffers + height * width * sizeof(pixel_t); vid_buffer = swap_frames[swap_current&1]; // Need to rewrite whole frame VID_WholeDamageBuffer(); - sintable = malloc((vid.width+CYCLE) * sizeof(int)); - intsintable = malloc((vid.width+CYCLE) * sizeof(int)); - blanktable = malloc((vid.width+CYCLE) * sizeof(int)); + sintable = malloc((width+CYCLE) * sizeof(int)); + intsintable = malloc((width+CYCLE) * sizeof(int)); + blanktable = malloc((width+CYCLE) * sizeof(int)); - newedges = malloc(vid.width * sizeof(edge_t *)); - removeedges = malloc(vid.width * sizeof(edge_t *)); + newedges = malloc(width * sizeof(edge_t *)); + removeedges = malloc(width * sizeof(edge_t *)); - warp_rowptr = malloc((vid.width+AMP2*2) * sizeof(byte*)); - warp_column = malloc((vid.width+AMP2*2) * sizeof(int)); + warp_rowptr = malloc((width+AMP2*2) * sizeof(byte*)); + warp_column = malloc((width+AMP2*2) * sizeof(int)); // count of "out of items" r_outofsurfaces = false; @@ -2374,9 +2375,10 @@ SWimp_CreateRender(void) R_ReallocateMapBuffers(); - r_warpbuffer = malloc(vid.height * vid.width * sizeof(pixel_t)); + r_warpbuffer = malloc(height * width * sizeof(pixel_t)); - if ((vid.width >= 2048) && (sizeof(shift20_t) == 4)) // 2k+ resolution and 32 == shift20_t + // 2k+ resolution and 32 == shift20_t + if ((width >= 2048) && (sizeof(shift20_t) == 4)) { shift_size = 18; } @@ -2385,9 +2387,9 @@ SWimp_CreateRender(void) shift_size = 20; } - R_InitTurb (); + R_InitTurb (width); - vid_polygon_spans = malloc(sizeof(espan_t) * (vid.height + 1)); + vid_polygon_spans = malloc(sizeof(espan_t) * (height + 1)); memset(sw_state.currentpalette, 0, sizeof(sw_state.currentpalette)); From 791b5e1e13584d851b009b53c62259b0f7052634 Mon Sep 17 00:00:00 2001 From: Denis Pauk Date: Sat, 6 Feb 2021 23:35:02 +0200 Subject: [PATCH 4/4] Save buffer size and use as limit for operations --- src/client/refresh/soft/header/local.h | 4 ++ src/client/refresh/soft/sw_draw.c | 70 ++++++++++---------- src/client/refresh/soft/sw_edge.c | 2 +- src/client/refresh/soft/sw_main.c | 88 ++++++++++++++------------ src/client/refresh/soft/sw_misc.c | 2 +- src/client/refresh/soft/sw_part.c | 18 +++--- src/client/refresh/soft/sw_poly.c | 4 +- src/client/refresh/soft/sw_polyset.c | 10 +-- src/client/refresh/soft/sw_scan.c | 18 +++--- src/client/refresh/soft/sw_surf.c | 2 +- 10 files changed, 114 insertions(+), 104 deletions(-) diff --git a/src/client/refresh/soft/header/local.h b/src/client/refresh/soft/header/local.h index 59d95adb..d6beaf0a 100644 --- a/src/client/refresh/soft/header/local.h +++ b/src/client/refresh/soft/header/local.h @@ -373,6 +373,10 @@ extern zvalue_t *d_pzbuffer; extern int d_minmip; extern float d_scalemip[NUM_MIPS-1]; +extern int vid_buffer_height; +extern int vid_buffer_width; + + //=================================================================== extern int cachewidth; diff --git a/src/client/refresh/soft/sw_draw.c b/src/client/refresh/soft/sw_draw.c index 6339e4db..52cec46a 100644 --- a/src/client/refresh/soft/sw_draw.c +++ b/src/client/refresh/soft/sw_draw.c @@ -95,7 +95,7 @@ RE_Draw_CharScaled(int x, int y, int c, float scale) if (y <= -8) return; // totally off screen - if ( ( y + 8 ) > vid.height ) // status text was missing in sw... + if ( ( y + 8 ) > vid_buffer_height ) // status text was missing in sw... return; row = c>>4; @@ -111,12 +111,12 @@ RE_Draw_CharScaled(int x, int y, int c, float scale) else drawline = 8; - dest = vid_buffer + y * vid.width + x; + dest = vid_buffer + y * vid_buffer_width + x; // clipped last lines - if ((y + iscale * (drawline + 1)) > vid.height) + if ((y + iscale * (drawline + 1)) > vid_buffer_height) { - drawline = (vid.height - y) / iscale; + drawline = (vid_buffer_height - y) / iscale; } VID_DamageBuffer(x, y); @@ -134,7 +134,7 @@ RE_Draw_CharScaled(int x, int y, int c, float scale) dest[u * iscale + xpos] = source[u]; } } - dest += vid.width; + dest += vid_buffer_width; } source += 128; } @@ -174,8 +174,8 @@ RE_Draw_StretchPicImplementation (int x, int y, int w, int h, const image_t *pic int skip; if ((x < 0) || - (x + w > vid.width) || - (y + h > vid.height)) + (x + w > vid_buffer_width) || + (y + h > vid_buffer_height)) { R_Printf(PRINT_ALL, "%s: bad coordinates %dx%d[%dx%d]", __func__, x, y, w, h); @@ -195,13 +195,13 @@ RE_Draw_StretchPicImplementation (int x, int y, int w, int h, const image_t *pic else skip = 0; - dest = vid_buffer + y * vid.width + x; + dest = vid_buffer + y * vid_buffer_width + x; if (w == pic->width) { int v; - for (v=0 ; vheight/h; source = pic->pixels[0] + sv*pic->width; @@ -219,7 +219,7 @@ RE_Draw_StretchPicImplementation (int x, int y, int w, int h, const image_t *pic if (sw_retexturing->value) { - if (pic_width < (vid.width / 3) || pic_height < (vid.height / 3)) + if (pic_width < (vid_buffer_width / 3) || pic_height < (vid_buffer_height / 3)) { image_scaled = malloc(pic_width * pic_height * 9); @@ -246,7 +246,7 @@ RE_Draw_StretchPicImplementation (int x, int y, int w, int h, const image_t *pic // size of screen tile to pic pixel int picupscale = h / pic_height; - for (v=0 ; vwidth * scale > vid.width) || - (y + pic->height * scale > vid.height)) + (x + pic->width * scale > vid_buffer_width) || + (y + pic->height * scale > vid_buffer_height)) { R_Printf(PRINT_ALL, "Draw_Pic: bad coordinates\n"); return; @@ -356,7 +356,7 @@ RE_Draw_PicScaled(int x, int y, char *name, float scale) y = 0; } - dest = vid_buffer + y * vid.width + x; + dest = vid_buffer + y * vid_buffer_width + x; VID_DamageBuffer(x, y); VID_DamageBuffer(x + iscale * pic->width, y + iscale * pic->height); @@ -368,7 +368,7 @@ RE_Draw_PicScaled(int x, int y, char *name, float scale) for (v=0; vwidth); - dest += vid.width; + dest += vid_buffer_width; source += pic->width; } } @@ -390,7 +390,7 @@ RE_Draw_PicScaled(int x, int y, char *name, float scale) } while (--xpos > 0); source_u++; } while (--u > 0); - dest += vid.width; + dest += vid_buffer_width; } source += pic->width; } @@ -407,7 +407,7 @@ RE_Draw_PicScaled(int x, int y, char *name, float scale) if (source[u] != TRANSPARENT_COLOR) dest[u] = source[u]; } - dest += vid.width; + dest += vid_buffer_width; source += pic->width; } } @@ -425,7 +425,7 @@ RE_Draw_PicScaled(int x, int y, char *name, float scale) dest[u * iscale + xpos] = source[u]; } } - dest += vid.width; + dest += vid_buffer_width; } source += pic->width; } @@ -460,10 +460,10 @@ RE_Draw_TileClear (int x, int y, int w, int h, char *name) h += y; y = 0; } - if (x + w > vid.width) - w = vid.width - x; - if (y + h > vid.height) - h = vid.height - y; + if (x + w > vid_buffer_width) + w = vid_buffer_width - x; + if (y + h > vid_buffer_height) + h = vid_buffer_height - y; if (w <= 0 || h <= 0) return; @@ -477,8 +477,8 @@ RE_Draw_TileClear (int x, int y, int w, int h, char *name) return; } x2 = x + w; - pdest = vid_buffer + y * vid.width; - for (i=0 ; ipixels[0] + pic->width * ((i+y)&63); for (j=x ; j vid.width) - w = vid.width - x; - if (y+h > vid.height) - h = vid.height - y; + if (x+w > vid_buffer_width) + w = vid_buffer_width - x; + if (y+h > vid_buffer_height) + h = vid_buffer_height - y; if (x < 0) { @@ -522,8 +522,8 @@ RE_Draw_Fill (int x, int y, int w, int h, int c) VID_DamageBuffer(x, y); VID_DamageBuffer(x + w, y + h); - dest = vid_buffer + y * vid.width + x; - for (v=0 ; vv + span->u; + pdest = d_viewbuffer + vid_buffer_width*span->v + span->u; memset(pdest, color&0xFF, span->count * sizeof(pixel_t)); } } diff --git a/src/client/refresh/soft/sw_main.c b/src/client/refresh/soft/sw_main.c index cc7040a6..0c168105 100644 --- a/src/client/refresh/soft/sw_main.c +++ b/src/client/refresh/soft/sw_main.c @@ -250,9 +250,9 @@ VID_DamageZBuffer(int u, int v) static void VID_NoDamageZBuffer(void) { - vid_zminu = vid.width; + vid_zminu = vid_buffer_width; vid_zmaxu = 0; - vid_zminv = vid.height; + vid_zminv = vid_buffer_height; vid_zmaxv = 0; } @@ -284,9 +284,9 @@ static void VID_WholeDamageZBuffer(void) { vid_zminu = 0; - vid_zmaxu = vid.width; + vid_zmaxu = vid_buffer_width; vid_zminv = 0; - vid_zmaxv = vid.height; + vid_zmaxv = vid_buffer_height; } /* @@ -323,9 +323,9 @@ VID_DamageBuffer(int u, int v) static void VID_NoDamageBuffer(void) { - vid_minu = vid.width; + vid_minu = vid_buffer_width; vid_maxu = 0; - vid_minv = vid.height; + vid_minv = vid_buffer_height; vid_maxv = 0; } @@ -334,9 +334,9 @@ static void VID_WholeDamageBuffer(void) { vid_minu = 0; - vid_maxu = vid.width; + vid_maxu = vid_buffer_width; vid_minv = 0; - vid_maxv = vid.height; + vid_maxv = vid_buffer_height; } /* @@ -714,8 +714,8 @@ R_ReallocateMapBuffers (void) } // used up to 8 * width spans for render, allocate once before use - if (r_numallocatededgebasespans < vid.width * 8) - r_numallocatededgebasespans = vid.width * 8; + if (r_numallocatededgebasespans < vid_buffer_width * 8) + r_numallocatededgebasespans = vid_buffer_width * 8; edge_basespans = malloc(r_numallocatededgebasespans * sizeof(espan_t)); if (!edge_basespans) @@ -1311,7 +1311,7 @@ RE_RenderFrame (refdef_t *fd) VectorCopy (fd->viewangles, r_refdef.viewangles); // compare current position with old - if (vid.width <= 640 || + if (vid_buffer_width <= 640 || !VectorCompareRound(fd->vieworg, lastvieworg) || !VectorCompare(fd->viewangles, lastviewangles)) { @@ -1461,7 +1461,7 @@ RE_BeginFrame( float camera_separation ) VID_WholeDamageBuffer(); // and backbuffer should be zeroed memset(swap_buffers + ((swap_current + 1)&1), 0, - vid.height * vid.width * sizeof(pixel_t)); + vid_buffer_height * vid_buffer_width * sizeof(pixel_t)); vid_gamma->modified = false; sw_overbrightbits->modified = false; @@ -1891,6 +1891,9 @@ static SDL_Window *window = NULL; static SDL_Texture *texture = NULL; static SDL_Renderer *renderer = NULL; +int vid_buffer_height = 0; +int vid_buffer_width = 0; + static int RE_InitContext(void *win) { @@ -1927,6 +1930,9 @@ RE_InitContext(void *win) This will show the new, black contents of the window. */ SDL_RenderPresent(renderer); + vid_buffer_height = vid.height; + vid_buffer_width = vid.width; + texture = SDL_CreateTexture(renderer, #if SDL_BYTEORDER == SDL_BIG_ENDIAN SDL_PIXELFORMAT_BGRA8888, @@ -1934,10 +1940,10 @@ RE_InitContext(void *win) SDL_PIXELFORMAT_ARGB8888, #endif SDL_TEXTUREACCESS_STREAMING, - vid.width, vid.height); + vid_buffer_width, vid_buffer_height); - R_InitGraphics(vid.width, vid.height); - SWimp_CreateRender(vid.width, vid.height); + R_InitGraphics(vid_buffer_width, vid_buffer_height); + SWimp_CreateRender(vid_buffer_width, vid_buffer_height); return true; } @@ -2069,7 +2075,7 @@ RE_CopyFrame (Uint32 * pixels, int pitch, int vmin, int vmax) Uint32 *sdl_palette = (Uint32 *)sw_state.currentpalette; // no gaps between images rows - if (pitch == vid.width) + if (pitch == vid_buffer_width) { const Uint32 *max_pixels; Uint32 *pixels_pos; @@ -2091,19 +2097,19 @@ RE_CopyFrame (Uint32 * pixels, int pitch, int vmin, int vmax) { int y,x, buffer_pos, ymin, ymax; - ymin = vmin / vid.width; - ymax = vmax / vid.width; + ymin = vmin / vid_buffer_width; + ymax = vmax / vid_buffer_width; - buffer_pos = ymin * vid.width; + buffer_pos = ymin * vid_buffer_width; pixels += ymin * pitch; for (y=ymin; y < ymax; y++) { - for (x=0; x < vid.width; x ++) + for (x=0; x < vid_buffer_width; x ++) { pixels[x] = sdl_palette[vid_buffer[buffer_pos + x]]; } pixels += pitch; - buffer_pos += vid.width; + buffer_pos += vid_buffer_width; } } } @@ -2148,7 +2154,7 @@ RE_CleanFrame(void) Uint32 *pixels; memset(swap_buffers, 0, - vid.height * vid.width * sizeof(pixel_t) * 2); + vid_buffer_height * vid_buffer_width * sizeof(pixel_t) * 2); if (SDL_LockTexture(texture, NULL, (void**)&pixels, &pitch)) { @@ -2157,7 +2163,7 @@ RE_CleanFrame(void) } // only cleanup texture without flush texture to screen - memset(pixels, 0, pitch * vid.height); + memset(pixels, 0, pitch * vid_buffer_height); SDL_UnlockTexture(texture); // All changes flushed @@ -2183,12 +2189,12 @@ RE_FlushFrame(int vmin, int vmax) { // On MacOS texture is cleaned up after render, // code have to copy a whole screen to the texture - RE_CopyFrame (pixels, pitch / sizeof(Uint32), 0, vid.height * vid.width); + RE_CopyFrame (pixels, pitch / sizeof(Uint32), 0, vid_buffer_height * vid_buffer_width); } if (((int)sw_texture_filtering->value & 0x01) && !fastmoving) { - SmoothColorImage(pixels + vmin, vmax - vmin, vid.width >> 7); + SmoothColorImage(pixels + vmin, vmax - vmin, vid_buffer_width >> 7); } SDL_UnlockTexture(texture); @@ -2224,22 +2230,22 @@ RE_EndFrame (void) { vid_minv = 0; } - if (vid_maxu > vid.width) + if (vid_maxu > vid_buffer_width) { - vid_maxu = vid.width; + vid_maxu = vid_buffer_width; } - if (vid_maxv > vid.height) + if (vid_maxv > vid_buffer_height) { - vid_maxv = vid.height; + vid_maxv = vid_buffer_height; } - vmin = vid_minu + vid_minv * vid.width; - vmax = vid_maxu + vid_maxv * vid.width; + vmin = vid_minu + vid_minv * vid_buffer_width; + vmax = vid_maxu + vid_maxv * vid_buffer_width; // fix to correct limit - if (vmax > (vid.height * vid.width)) + if (vmax > (vid_buffer_height * vid_buffer_width)) { - vmax = vid.height * vid.width; + vmax = vid_buffer_height * vid_buffer_width; } // if palette changed need to flush whole buffer @@ -2256,9 +2262,9 @@ RE_EndFrame (void) // search difference end vmax = RE_BufferDifferenceEnd(vmin, vmax); - if (vmax > (vid.height * vid.width)) + if (vmax > (vid_buffer_height * vid_buffer_width)) { - vmax = vid.height * vid.width; + vmax = vid_buffer_height * vid_buffer_width; } } @@ -2436,26 +2442,26 @@ static void R_ScreenShot_f(void) { int x, y; - byte *buffer = malloc(vid.width * vid.height * 3); + byte *buffer = malloc(vid_buffer_width * vid_buffer_height * 3); const unsigned char *palette = sw_state.currentpalette; if (!buffer) { - R_Printf(PRINT_ALL, "R_ScreenShot: Couldn't malloc %d bytes\n", vid.width * vid.height * 3); + R_Printf(PRINT_ALL, "R_ScreenShot: Couldn't malloc %d bytes\n", vid_buffer_width * vid_buffer_height * 3); return; } - for (x=0; x < vid.width; x ++) + for (x=0; x < vid_buffer_width; x ++) { - for (y=0; y < vid.height; y ++) { - int buffer_pos = y * vid.width + x; + for (y=0; y < vid_buffer_height; y ++) { + int buffer_pos = y * vid_buffer_width + x; buffer[buffer_pos * 3 + 0] = palette[vid_buffer[buffer_pos] * 4 + 2]; // red buffer[buffer_pos * 3 + 1] = palette[vid_buffer[buffer_pos] * 4 + 1]; // green buffer[buffer_pos * 3 + 2] = palette[vid_buffer[buffer_pos] * 4 + 0]; // blue } } - ri.Vid_WriteScreenshot(vid.width, vid.height, 3, buffer); + ri.Vid_WriteScreenshot(vid_buffer_width, vid_buffer_height, 3, buffer); free(buffer); } diff --git a/src/client/refresh/soft/sw_misc.c b/src/client/refresh/soft/sw_misc.c index bf0a5a72..0f5eef26 100644 --- a/src/client/refresh/soft/sw_misc.c +++ b/src/client/refresh/soft/sw_misc.c @@ -66,7 +66,7 @@ D_ViewChanged (void) */ if ( r_newrefdef.rdflags & RDF_NOWORLDMODEL ) { - memset( d_pzbuffer, 0xff, vid.width * vid.height * sizeof(zvalue_t) ); + memset( d_pzbuffer, 0xff, vid_buffer_width * vid_buffer_height * sizeof(zvalue_t) ); RE_Draw_Fill( r_newrefdef.x, r_newrefdef.y, r_newrefdef.width, r_newrefdef.height,( int ) sw_clearcolor->value & 0xff ); } } diff --git a/src/client/refresh/soft/sw_part.c b/src/client/refresh/soft/sw_part.c index be283d22..b7c620f4 100644 --- a/src/client/refresh/soft/sw_part.c +++ b/src/client/refresh/soft/sw_part.c @@ -83,8 +83,8 @@ R_DrawParticle(particle_t *pparticle, int level) ** compute addresses of zbuffer, framebuffer, and ** compute the Z-buffer reference value. */ - pz = d_pzbuffer + (vid.width * v) + u; - pdest = d_viewbuffer + vid.width * v + u; + pz = d_pzbuffer + (vid_buffer_width * v) + u; + pdest = d_viewbuffer + vid_buffer_width * v + u; izi = (int)(zi * 0x8000); /* @@ -101,7 +101,7 @@ R_DrawParticle(particle_t *pparticle, int level) ** render the appropriate pixels */ count = pix; - if ((pz[(vid.width * count / 2) + (count / 2)]) > izi) + if ((pz[(vid_buffer_width * count / 2) + (count / 2)]) > izi) { // looks like under some object return; @@ -115,7 +115,7 @@ R_DrawParticle(particle_t *pparticle, int level) { switch (level) { case PARTICLE_33 : - for ( ; count ; count--, pz += vid.width, pdest += vid.width) + for ( ; count ; count--, pz += vid_buffer_width, pdest += vid_buffer_width) { //FIXME--do it in blocks of 8? for (i=0 ; iv) + pspan->u; - s_spanletvars.pz = d_pzbuffer + (vid.width * pspan->v) + pspan->u; + s_spanletvars.pdest = d_viewbuffer + (vid_buffer_width * pspan->v) + pspan->u; + s_spanletvars.pz = d_pzbuffer + (vid_buffer_width * pspan->v) + pspan->u; s_spanletvars.u = pspan->u; s_spanletvars.v = pspan->v; count = pspan->count; diff --git a/src/client/refresh/soft/sw_polyset.c b/src/client/refresh/soft/sw_polyset.c index b6e0d2d1..bd4544a8 100644 --- a/src/client/refresh/soft/sw_polyset.c +++ b/src/client/refresh/soft/sw_polyset.c @@ -454,7 +454,7 @@ R_PolysetDrawSpans8_33(const entity_t *currententity, spanpackage_t *pspanpackag if (lcount > 0) { - int pos_shift = (pspanpackage->v * vid.width) + pspanpackage->u; + int pos_shift = (pspanpackage->v * vid_buffer_width) + pspanpackage->u; lpdest = d_viewbuffer + pos_shift; lpz = d_pzbuffer + pos_shift; @@ -518,7 +518,7 @@ R_PolysetDrawSpansConstant8_33(const entity_t *currententity, spanpackage_t *psp if (lcount > 0) { - int pos_shift = (pspanpackage->v * vid.width) + pspanpackage->u; + int pos_shift = (pspanpackage->v * vid_buffer_width) + pspanpackage->u; lpdest = d_viewbuffer + pos_shift; lpz = d_pzbuffer + pos_shift; @@ -568,7 +568,7 @@ R_PolysetDrawSpans8_66(const entity_t *currententity, spanpackage_t *pspanpackag if (lcount > 0) { - int pos_shift = (pspanpackage->v * vid.width) + pspanpackage->u; + int pos_shift = (pspanpackage->v * vid_buffer_width) + pspanpackage->u; qboolean zdamaged = false; lpdest = d_viewbuffer + pos_shift; @@ -644,7 +644,7 @@ R_PolysetDrawSpansConstant8_66(const entity_t *currententity, spanpackage_t *psp if (lcount > 0) { - int pos_shift = (pspanpackage->v * vid.width) + pspanpackage->u; + int pos_shift = (pspanpackage->v * vid_buffer_width) + pspanpackage->u; qboolean zdamaged = false; lpdest = d_viewbuffer + pos_shift; @@ -703,7 +703,7 @@ R_PolysetDrawSpans8_Opaque (const entity_t *currententity, spanpackage_t *pspanp int llight; zvalue_t lzi; zvalue_t *lpz; - int pos_shift = (pspanpackage->v * vid.width) + pspanpackage->u; + int pos_shift = (pspanpackage->v * vid_buffer_width) + pspanpackage->u; qboolean zdamaged = false; lpdest = d_viewbuffer + pos_shift; diff --git a/src/client/refresh/soft/sw_scan.c b/src/client/refresh/soft/sw_scan.c index 0c012b42..dcd97764 100644 --- a/src/client/refresh/soft/sw_scan.c +++ b/src/client/refresh/soft/sw_scan.c @@ -62,7 +62,7 @@ D_WarpScreen (void) int v2; v2 = (int)((float)v/(h + AMP2 * 2) * r_refdef.vrect.height); - warp_rowptr[v] = r_warpbuffer + (vid.width * v2); + warp_rowptr[v] = r_warpbuffer + (vid_buffer_width * v2); } for (u=0 ; u> SHIFT16XYZ == 0 && count < vid.width) + while ((izistep * count) >> SHIFT16XYZ == 0 && count < vid_buffer_width) { count <<= 1; } @@ -209,7 +209,7 @@ TurbulentPow2 (espan_t *pspan, float d_ziorigin, float d_zistepu, float d_zistep float sdivz, tdivz, zi, z, du, dv; pixel_t *r_turb_pdest; - r_turb_pdest = d_viewbuffer + (vid.width * pspan->v) + pspan->u; + r_turb_pdest = d_viewbuffer + (vid_buffer_width * pspan->v) + pspan->u; count = pspan->count; @@ -363,7 +363,7 @@ NonTurbulentPow2 (espan_t *pspan, float d_ziorigin, float d_zistepu, float d_zis float sdivz, tdivz, zi, z, dv, du; pixel_t *r_turb_pdest; - r_turb_pdest = d_viewbuffer + (vid.width * pspan->v) + pspan->u; + r_turb_pdest = d_viewbuffer + (vid_buffer_width * pspan->v) + pspan->u; count = pspan->count; @@ -616,7 +616,7 @@ D_DrawSpansPow2 (espan_t *pspan, float d_ziorigin, float d_zistepu, float d_zist int count, s, t; float sdivz, tdivz, zi, z, du, dv; - pdest = d_viewbuffer + (vid.width * pspan->v) + pspan->u; + pdest = d_viewbuffer + (vid_buffer_width * pspan->v) + pspan->u; count = pspan->count; @@ -769,7 +769,7 @@ D_DrawZSpans (espan_t *pspan, float d_ziorigin, float d_zistepu, float d_zistepv VID_DamageZBuffer(pspan->u, pspan->v); VID_DamageZBuffer(pspan->u + pspan->count, pspan->v); - pdest = d_pzbuffer + (vid.width * pspan->v) + pspan->u; + pdest = d_pzbuffer + (vid_buffer_width * pspan->v) + pspan->u; count = pspan->count; diff --git a/src/client/refresh/soft/sw_surf.c b/src/client/refresh/soft/sw_surf.c index ca79b63a..16085e4b 100644 --- a/src/client/refresh/soft/sw_surf.c +++ b/src/client/refresh/soft/sw_surf.c @@ -217,7 +217,7 @@ R_InitCaches (void) // surface cache size at 320X240 size = 1024*768; - pix = vid.width*vid.height; + pix = vid_buffer_width*vid_buffer_height; if (pix > 64000) size += (pix-64000)*3;