mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
commit
d86905119e
11 changed files with 180 additions and 137 deletions
|
@ -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;
|
||||
|
|
|
@ -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,10 +174,12 @@ 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))
|
||||
{
|
||||
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);
|
||||
|
@ -193,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 ; v<height ; v++, dest += vid.width)
|
||||
for (v=0 ; v<height ; v++, dest += vid_buffer_width)
|
||||
{
|
||||
int sv = (skip + v)*pic->height/h;
|
||||
source = pic->pixels[0] + sv*pic->width;
|
||||
|
@ -217,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);
|
||||
|
||||
|
@ -244,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 ; v<height ; v++, dest += vid.width)
|
||||
for (v=0 ; v<height ; v++, dest += vid_buffer_width)
|
||||
{
|
||||
int f, fstep, u;
|
||||
int sv = (skip + v)*pic_height/h;
|
||||
|
@ -265,7 +267,7 @@ RE_Draw_StretchPicImplementation (int x, int y, int w, int h, const image_t *pic
|
|||
for (i=1; i < picupscale; i++)
|
||||
{
|
||||
// go to next line
|
||||
dest += vid.width;
|
||||
dest += vid_buffer_width;
|
||||
memcpy (dest, dest_orig, w);
|
||||
}
|
||||
// skip updated lines
|
||||
|
@ -338,8 +340,8 @@ RE_Draw_PicScaled(int x, int y, char *name, float scale)
|
|||
}
|
||||
|
||||
if ((x < 0) ||
|
||||
(x + pic->width * 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;
|
||||
|
@ -354,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);
|
||||
|
@ -366,7 +368,7 @@ RE_Draw_PicScaled(int x, int y, char *name, float scale)
|
|||
for (v=0; v<height; v++)
|
||||
{
|
||||
memcpy(dest, source, pic->width);
|
||||
dest += vid.width;
|
||||
dest += vid_buffer_width;
|
||||
source += pic->width;
|
||||
}
|
||||
}
|
||||
|
@ -388,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;
|
||||
}
|
||||
|
@ -405,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;
|
||||
}
|
||||
}
|
||||
|
@ -423,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;
|
||||
}
|
||||
|
@ -458,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;
|
||||
|
||||
|
@ -475,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 ; i<h ; i++, pdest += vid.width)
|
||||
pdest = vid_buffer + y * vid_buffer_width;
|
||||
for (i=0 ; i<h ; i++, pdest += vid_buffer_width)
|
||||
{
|
||||
psrc = pic->pixels[0] + pic->width * ((i+y)&63);
|
||||
for (j=x ; j<x2 ; j++)
|
||||
|
@ -498,10 +500,10 @@ RE_Draw_Fill (int x, int y, int w, int h, int c)
|
|||
pixel_t *dest;
|
||||
int v;
|
||||
|
||||
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 (x < 0)
|
||||
{
|
||||
|
@ -520,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 ; v<h ; v++, dest += vid.width)
|
||||
dest = vid_buffer + y * vid_buffer_width + x;
|
||||
for (v=0 ; v<h ; v++, dest += vid_buffer_width)
|
||||
memset(dest, c, w);
|
||||
}
|
||||
//=============================================================================
|
||||
|
@ -538,17 +540,17 @@ RE_Draw_FadeScreen (void)
|
|||
int x,y;
|
||||
|
||||
VID_DamageBuffer(0, 0);
|
||||
VID_DamageBuffer(vid.width, vid.height);
|
||||
VID_DamageBuffer(vid_buffer_width, vid_buffer_height);
|
||||
|
||||
for (y=0 ; y<vid.height ; y++)
|
||||
for (y=0 ; y<vid_buffer_height ; y++)
|
||||
{
|
||||
int t;
|
||||
pixel_t *pbuf;
|
||||
|
||||
pbuf = vid_buffer + vid.width * y;
|
||||
pbuf = vid_buffer + vid_buffer_width * y;
|
||||
t = (y & 1) << 1;
|
||||
|
||||
for (x=0 ; x<vid.width ; x++)
|
||||
for (x=0 ; x<vid_buffer_width ; x++)
|
||||
{
|
||||
if ((x & 3) != t)
|
||||
pbuf[x] = 0;
|
||||
|
|
|
@ -766,7 +766,7 @@ D_FlatFillSurface (surf_t *surf, pixel_t color)
|
|||
{
|
||||
pixel_t *pdest;
|
||||
|
||||
pdest = d_viewbuffer + vid.width*span->v + span->u;
|
||||
pdest = d_viewbuffer + vid_buffer_width*span->v + span->u;
|
||||
memset(pdest, color&0xFF, span->count * sizeof(pixel_t));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1301,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))
|
||||
{
|
||||
|
@ -1400,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 )
|
||||
{
|
||||
|
@ -1418,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();
|
||||
|
||||
|
@ -1453,7 +1460,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_buffer_height * vid_buffer_width * sizeof(pixel_t));
|
||||
|
||||
vid_gamma->modified = false;
|
||||
sw_overbrightbits->modified = false;
|
||||
|
@ -1488,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 */
|
||||
|
@ -1503,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__);
|
||||
|
@ -1887,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)
|
||||
{
|
||||
|
@ -1923,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,
|
||||
|
@ -1930,7 +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_buffer_width, vid_buffer_height);
|
||||
SWimp_CreateRender(vid_buffer_width, vid_buffer_height);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -2062,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;
|
||||
|
@ -2084,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2140,7 +2153,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_buffer_height * vid_buffer_width * sizeof(pixel_t) * 2);
|
||||
|
||||
if (SDL_LockTexture(texture, NULL, (void**)&pixels, &pitch))
|
||||
{
|
||||
|
@ -2149,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
|
||||
|
@ -2175,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);
|
||||
|
@ -2216,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
|
||||
|
@ -2248,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2285,22 +2299,42 @@ 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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
if (!ri.GLimp_InitGraphics(fullscreen, pwidth, pheight))
|
||||
{
|
||||
// failed to set a valid mode in windowed mode
|
||||
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__);
|
||||
|
@ -2308,20 +2342,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;
|
||||
|
@ -2347,9 +2381,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;
|
||||
}
|
||||
|
@ -2358,9 +2393,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));
|
||||
|
||||
|
@ -2407,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);
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 ; i<pix ; i++)
|
||||
|
@ -132,7 +132,7 @@ R_DrawParticle(particle_t *pparticle, int level)
|
|||
case PARTICLE_66 :
|
||||
{
|
||||
int color_part = (color<<8);
|
||||
for ( ; count ; count--, pz += vid.width, pdest += vid.width)
|
||||
for ( ; count ; count--, pz += vid_buffer_width, pdest += vid_buffer_width)
|
||||
{
|
||||
for (i=0 ; i<pix ; i++)
|
||||
{
|
||||
|
@ -147,7 +147,7 @@ R_DrawParticle(particle_t *pparticle, int level)
|
|||
}
|
||||
|
||||
default: //100
|
||||
for ( ; count ; count--, pz += vid.width, pdest += vid.width)
|
||||
for ( ; count ; count--, pz += vid_buffer_width, pdest += vid_buffer_width)
|
||||
{
|
||||
for (i=0 ; i<pix ; i++)
|
||||
{
|
||||
|
@ -169,7 +169,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 ; i<pix ; i++)
|
||||
|
@ -187,7 +187,7 @@ R_DrawParticle(particle_t *pparticle, int level)
|
|||
case PARTICLE_66 :
|
||||
{
|
||||
int color_part = (color<<8);
|
||||
for ( ; count ; count--, pz += vid.width, pdest += vid.width)
|
||||
for ( ; count ; count--, pz += vid_buffer_width, pdest += vid_buffer_width)
|
||||
{
|
||||
for (i=0 ; i<pix ; i++)
|
||||
{
|
||||
|
@ -203,7 +203,7 @@ R_DrawParticle(particle_t *pparticle, int level)
|
|||
}
|
||||
|
||||
default: //100
|
||||
for ( ; count ; count--, pz += vid.width, pdest += vid.width)
|
||||
for ( ; count ; count--, pz += vid_buffer_width, pdest += vid_buffer_width)
|
||||
{
|
||||
for (i=0 ; i<pix ; i++)
|
||||
{
|
||||
|
|
|
@ -621,8 +621,8 @@ R_PolygonDrawSpans(espan_t *pspan, int iswater, float d_ziorigin, float d_zistep
|
|||
{
|
||||
int count;
|
||||
|
||||
s_spanletvars.pdest = d_viewbuffer + (vid.width * pspan->v) + 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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<w+AMP2*2 ; u++)
|
||||
|
@ -75,9 +75,9 @@ D_WarpScreen (void)
|
|||
}
|
||||
|
||||
turb = intsintable + ((int)(r_newrefdef.time*SPEED)&(CYCLE-1));
|
||||
dest = vid_buffer + r_newrefdef.y * vid.width + r_newrefdef.x;
|
||||
dest = vid_buffer + r_newrefdef.y * vid_buffer_width + r_newrefdef.x;
|
||||
|
||||
for (v=0 ; v<h ; v++, dest += vid.width)
|
||||
for (v=0 ; v<h ; v++, dest += vid_buffer_width)
|
||||
{
|
||||
int *col;
|
||||
|
||||
|
@ -127,7 +127,7 @@ D_DrawSpanGetStep(float d_zistepu, float d_zistepv)
|
|||
}
|
||||
|
||||
}
|
||||
while (spanzshift_value < vid.width);
|
||||
while (spanzshift_value < vid_buffer_width);
|
||||
}
|
||||
return spanzshift;
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ D_DrawZSpanGetStepValue(zvalue_t izistep)
|
|||
// (both ends have same z value)
|
||||
int count = 1;
|
||||
|
||||
while ((izistep * count) >> 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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue